:root {
    --primary: var(--brand-primary, #165DFF);
    --primary-light: var(--brand-primary-light, #E8F4FF);
    --success: var(--color-success, #00B42A);
    --warning: var(--color-warning, #FF7D00);
    --danger: var(--color-danger, #F53F3F);
    --dark: var(--gray-900, #1D2129);
    --gray: var(--gray-700, #86909C);
    --light-gray: var(--bg-tertiary, #F2F3F5);
    --border: var(--border-color, #E5E6EB);
    --shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,0.08));
    --shadow-lg: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.12));

    --nav-height: 56px;
    --bottom-nav-height: 64px;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--light-gray);
    color: var(--dark);
    padding-top: var(--nav-height);
    padding-bottom: var(--bottom-nav-height);
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0;
    }
}

.navbar-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: white;
    border-bottom: 1px solid var(--border);
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary) !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand img {
    height: 32px;
    width: auto;
}

.nav-desktop {
    display: none;
}

@media (min-width: 992px) {
    .nav-desktop {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: auto;
    }

    .nav-desktop .nav-link {
        padding: 8px 16px;
        color: var(--dark);
        font-weight: 500;
        border-radius: 8px;
        transition: all 0.2s;
    }

    .nav-desktop .nav-link:hover,
    .nav-desktop .nav-link.active {
        background: var(--primary-light);
        color: var(--primary);
    }
}

.navbar-toggler-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--dark);
    font-size: 1.5rem;
    margin-left: auto;
}

@media (min-width: 992px) {
    .navbar-toggler-mobile {
        display: none;
    }
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.mobile-menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1050;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.mobile-menu.show {
    right: 0;
}

.mobile-menu-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    font-size: 1.5rem;
}

.mobile-menu-body {
    padding: 16px;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: var(--dark);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    font-weight: 500;
}

.mobile-menu-item:hover,
.mobile-menu-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.mobile-menu-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@media (min-width: 992px) {
    .nav-bottom {
        display: none;
    }
}

.nav-bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--gray);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s;
    flex: 1;
}

.nav-bottom-item.active {
    color: var(--primary);
}

.nav-bottom-item i {
    font-size: 1.25rem;
}

.main-content {
    min-height: calc(100vh - var(--nav-height) - var(--bottom-nav-height));
}

@media (min-width: 992px) {
    .main-content {
        min-height: calc(100vh - var(--nav-height));
    }
}

.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 40px 16px;
    margin-bottom: var(--bottom-nav-height);
}

@media (min-width: 992px) {
    .footer {
        margin-bottom: 0;
        padding: 60px 0;
    }
}

.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, #2B6AFF 100%);
    color: white;
    padding: 32px 16px;
    margin-bottom: 24px;
}

@media (min-width: 992px) {
    .page-header {
        padding: 48px 0;
    }
}

.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.btn-primary-custom {
    background: var(--primary);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary-custom:hover {
    background: #0E4AD6;
    color: white;
    transform: translateY(-2px);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.toast-container {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    padding: 0 16px;
    width: 100%;
    max-width: 400px;
}

.toast-custom {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.global-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.global-loading.show {
    display: flex;
}

.global-loading .loading-spinner {
    text-align: center;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light, #E8F4FF);
    border-top-color: var(--primary, #165DFF);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.loading-text {
    color: var(--dark, #1D2129);
    font-size: 14px;
    font-weight: 500;
}

.toast-container {
    position: fixed;
    top: calc(var(--nav-height, 56px) + 16px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast-message {
    background: white;
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 90vw;
    animation: slideDown 0.3s ease;
    pointer-events: auto;
}

.toast-message.hiding {
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.toast-message.success {
    border-left: 4px solid var(--success, #00B42A);
}

.toast-message.error {
    border-left: 4px solid var(--danger, #F53F3F);
}

.toast-message.warning {
    border-left: 4px solid var(--warning, #FF7D00);
}

.toast-message.info {
    border-left: 4px solid var(--primary, #165DFF);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message.success .toast-icon {
    color: var(--success, #00B42A);
}

.toast-message.error .toast-icon {
    color: var(--danger, #F53F3F);
}

.toast-message.warning .toast-icon {
    color: var(--warning, #FF7D00);
}

.toast-message.info .toast-icon {
    color: var(--primary, #165DFF);
}

.toast-content {
    flex: 1;
    font-size: 14px;
    color: var(--dark, #1D2129);
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray, #86909C);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--dark, #1D2129);
}
