/* ===== GLOBAL RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

/* ===== ROOT VARIABLES ===== */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

/* ===== BASE STYLES ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    padding-top: 56px; /* Fixed navbar height */
    min-height: 100vh;
}

/* ===== NAVBAR FIXES ===== */
.navbar {
    min-height: 56px;
    height: 56px;
    z-index: 1030;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
}

/* Fix dropdown positioning */
.navbar-nav .dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
    margin-top: 0.5rem;
    z-index: 1100;
    top: 100%;
}

/* On mobile, ensure dropdown is properly positioned */
@media (max-width: 767.98px) {
    .navbar-nav .dropdown-menu {
        position: absolute;
        right: 0;
        left: auto;
        top: 56px;
        width: 200px;
        min-width: 200px;
    }
}

/* Navbar brand positioning */
.navbar-brand {
    margin-left: 50px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
}

/* Toggle button positioning */
.navbar-toggler {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    margin: 0;
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.1);
}

/* User dropdown link styling */
.nav-link.dropdown-toggle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
}

@media (max-width: 767.98px) {
    .nav-link.dropdown-toggle {
        max-width: 150px;
        padding: 0.5rem;
    }
    
    .navbar-brand {
        margin-left: 60px;
    }
}

/* Offcanvas header */
.offcanvas-header {
    min-height: 56px;
    height: 56px;
    padding: 0.5rem 1rem;
}

/* Fix for dropdown menu items */
.dropdown-item {
    padding: 0.5rem 1rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* Ensure proper spacing in header */
.navbar-nav {
    align-items: center;
    margin: 0;
    height: 56px;
}

.navbar-nav > .nav-item {
    height: 100%;
    display: flex;
    align-items: center;
}

.navbar-nav > .nav-item > .nav-link {
    height: 100%;
    display: flex;
    align-items: center;
}

/* ===== SIDEBAR LAYOUT ===== */

/* Sidebar styling */
.sidebar {
    min-height: calc(100vh - 56px);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 250px;
    z-index: 100;
    overflow-y: auto;
}

.sidebar .nav-link {
    color: #333;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    transition: all 0.3s ease;
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar .nav-link:hover:not(.active) {
    background-color: #e9ecef;
}

/* Main content adjustment */
.col-md-9, main {
    margin-left: 250px;
    padding-top: 20px;
    width: calc(100% - 250px);
    min-height: calc(100vh - 56px);
}

/* Mobile adjustments */
@media (max-width: 767.98px) {
    .sidebar {
        display: none;
    }
    
    .col-md-9, main {
        margin-left: 0;
        width: 100%;
    }
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== CARDS ===== */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
}

/* Feature Cards */
.feature-card {
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    background: white;
    border: none;
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card i {
    margin-bottom: 1rem;
}

/* Stats Cards with Border Left */
.border-left-primary {
    border-left: 0.25rem solid var(--primary-color);
}

.border-left-warning {
    border-left: 0.25rem solid var(--warning-color);
}

.border-left-info {
    border-left: 0.25rem solid var(--info-color);
}

.border-left-success {
    border-left: 0.25rem solid var(--success-color);
}

/* Gradient Background Cards */
.bg-primary, .bg-success, .bg-info, .bg-warning {
    border: none;
}

.bg-primary {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
}

.bg-success {
    background: linear-gradient(135deg, var(--success-color), #1e7e34);
}

.bg-info {
    background: linear-gradient(135deg, var(--info-color), #138496);
}

.bg-warning {
    background: linear-gradient(135deg, var(--warning-color), #e0a800);
}

/* ===== TABLES ===== */
.table th {
    border-top: none;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    background-color: #f8f9fa;
}

.table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.table-sm th, .table-sm td {
    padding: 0.5rem;
}

/* ===== FORMS ===== */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border-radius: 0.375rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ===== BUTTONS ===== */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    border: none;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ===== ALERTS ===== */
.alert {
    border: none;
    border-radius: 10px;
    border-left: 4px solid transparent;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-left-color: var(--success-color);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-left-color: var(--danger-color);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-left-color: var(--warning-color);
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    border-left-color: var(--info-color);
}

.alert-primary {
    background-color: rgba(0, 123, 255, 0.1);
    border-left-color: var(--primary-color);
}

/* ===== BADGES ===== */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    padding: 0.5em 0.75em;
}

/* Status Badges */
.status-pending {
    background-color: var(--warning-color);
}

.status-approved {
    background-color: var(--success-color);
}

.status-rejected {
    background-color: var(--danger-color);
}

.status-open {
    background-color: var(--info-color);
}

.status-closed {
    background-color: var(--secondary-color);
}

/* ===== UTILITY CLASSES ===== */

/* Text Colors */
.text-gray-800 {
    color: #5a5c69;
}

.text-gray-300 {
    color: #dddfeb;
}

.text-xs {
    font-size: 0.7rem;
}

.font-weight-bold {
    font-weight: 700;
}

.text-uppercase {
    text-transform: uppercase;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Price Indicators */
.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.price-up {
    color: var(--success-color);
}

.price-down {
    color: var(--danger-color);
}

/* Shadows */
.shadow {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.shadow-custom {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08);
}

/* ===== SPECIAL COMPONENTS ===== */

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Crypto Icons */
.crypto-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.img-crypto {
    max-width: 100%;
    height: auto;
}

/* Message History */
.message-history {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.message-history::-webkit-scrollbar {
    width: 6px;
}

.message-history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.message-history::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.message-history::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Progress Bar */
.progress {
    border-radius: 4px;
}

.progress-bar {
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Avatar Circles */
.rounded-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .sidebar {
        min-height: auto;
        margin-bottom: 2rem;
    }
    
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-section .display-4 {
        font-size: 2rem;
    }
    
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

/* ===== FOOTER ===== */
footer {
    margin-top: auto;
}

/* ===== ADMIN SPECIFIC STYLES ===== */
.stats-card:hover {
    transform: translateY(-5px);
    transition: transform 0.3s ease;
}

.quick-action-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.admin-sidebar {
    min-height: calc(100vh - 76px);
}

/* ===== CONTAINER FIXES ===== */
.container-fluid {
    padding-left: 0;
    padding-right: 0;
}

.container-fluid > .row {
    margin-left: 0;
    margin-right: 0;
}

/* ===== OFF CANVAS FIXES ===== */
.offcanvas-start {
    width: 280px;
}

.offcanvas-body .sidebar {
    display: block;
    position: static;
    width: 100%;
    min-height: calc(100vh - 56px);
}

/* ===== DROPDOWN FIXES ===== */
.nav-link.dropdown-toggle {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 100%;
}

.nav-link.dropdown-toggle i.fa-chevron-down {
    font-size: 0.9rem;
    opacity: 0.8;
}

.nav-link.dropdown-toggle:hover i.fa-chevron-down {
    opacity: 1;
}

.nav-link.dropdown-toggle i.fa-user-circle {
    font-size: 1.2rem;
}

/* Dropdown menu styling */
.dropdown-menu {
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 0.375rem;
}

.dropdown-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
    border-bottom: 1px solid #f1f1f1;
    margin-bottom: 0.25rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    padding-left: 1.25rem;
}

.dropdown-item.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.dropdown-divider {
    margin: 0.25rem 0;
}

/* Mobile adjustments */
@media (max-width: 767.98px) {
    .nav-link.dropdown-toggle {
        min-width: 44px;
        padding: 0.5rem;
    }
    
    .nav-link.dropdown-toggle i.fa-user-circle {
        font-size: 1.4rem;
    }
}

/* Hover effects */
.nav-link.dropdown-toggle:hover {
    background-color: rgba(255,255,255,0.1);
    border-radius: 0.25rem;
}