/* RAAD ERP Super Admin Styles */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --primary-color: #667eea;
    --secondary-color: #764ba2;
}

body {
    min-height: 100vh;
    background-color: #f8f9fa;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding-top: 1rem;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow-y: auto;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.5rem;
    margin-bottom: 2rem;
}

.sidebar.collapsed .sidebar-header {
    flex-direction: column;
    padding: 0;
}

.sidebar-brand {
    padding: 1rem 1rem;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand {
    padding: 0.5rem;
    font-size: 1.2rem;
}

.sidebar-brand:hover {
    color: white;
}

.sidebar-collapse-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-collapse-btn i {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

.sidebar-text {
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

@media (min-width: 992px) {
    .sidebar-collapse-btn {
        display: flex;
    }
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-item {
    margin-bottom: 0.5rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s;
    position: relative;
}

.sidebar-nav-link:hover,
.sidebar-nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav-link i {
    margin-right: 0.75rem;
    font-size: 1.2rem;
    min-width: 1.2rem;
    text-align: center;
}

.sidebar.collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 0.875rem 0.5rem;
}

.sidebar.collapsed .sidebar-nav-link i {
    margin-right: 0;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Bar */
.topbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

/* Content Area */
.content-area {
    padding: 2rem;
}

/* Card Styles */
.card {
    border: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 10px 10px 0 0 !important;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
}

.btn-primary:hover {
    opacity: 0.9;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

/* Table Styles */
.table {
    background: white;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

/* Badge Styles */
.badge {
    padding: 0.35rem 0.65rem;
    font-weight: 500;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-card {
    max-width: 450px;
    width: 100%;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
    background: white;
    border-radius: 15px 15px 0 0;
}

.login-header h3 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-body {
    padding: 2rem;
    background: white;
    border-radius: 0 0 15px 15px;
}

/* Tab Styles */
.nav-tabs {
    border-bottom: 2px solid #dee2e6;
}

.nav-tabs .nav-link {
    border: none;
    color: #6c757d;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
}

.nav-tabs .nav-link:hover {
    border: none;
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    border: none;
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
}

/* Modal Styles */
.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Search Box */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Stats Card */
.stats-card {
    border-left: 4px solid var(--primary-color);
}

.stats-card .stats-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

/* Alert Styles */
.alert {
    border-radius: 8px;
    border: none;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ==================================
   MOBILE RESPONSIVENESS
   ================================== */

/* Hamburger Menu Toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1050;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
}

.sidebar-toggle i {
    font-size: 1.25rem;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* Loading Spinner */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 3px solid white;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

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

.spinner-primary {
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top: 3px solid var(--primary-color);
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* Loading State for Buttons */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* Toast Container */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
}

.toast {
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-header {
    font-weight: 600;
}

/* Mobile Table - Card View */
.mobile-card-view {
    display: none;
}

.mobile-card-view .card {
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

.mobile-card-view .card-body {
    padding: 1rem;
}

.mobile-card-view .data-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-card-view .data-row:last-child {
    border-bottom: none;
}

.mobile-card-view .data-label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.875rem;
}

.mobile-card-view .data-value {
    text-align: right;
    color: #212529;
}

.mobile-card-view .actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Touch-Friendly Buttons */
.btn-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.25rem;
}

.btn-group .btn {
    min-height: 38px;
}

/* Responsive Breakpoints */

/* Tablets and below (< 992px) */
@media (max-width: 991.98px) {
    /* Show hamburger menu */
    .sidebar-toggle {
        display: flex;
    }

    /* Hide collapse button on mobile */
    .sidebar-collapse-btn {
        display: none !important;
    }

    /* Hide sidebar by default */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: var(--sidebar-width) !important;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.3);
    }

    /* Remove collapsed state on mobile */
    .sidebar.collapsed {
        width: var(--sidebar-width) !important;
    }

    .sidebar.collapsed .sidebar-text {
        opacity: 1 !important;
        width: auto !important;
    }

    .sidebar.collapsed .sidebar-nav-link {
        justify-content: flex-start !important;
        padding: 0.875rem 1.5rem !important;
    }

    .sidebar.collapsed .sidebar-nav-link i {
        margin-right: 0.75rem !important;
    }

    /* Adjust main content */
    .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    /* Adjust topbar for mobile */
    .topbar {
        padding: 1rem;
        padding-left: 4rem; /* Space for hamburger */
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .topbar h5 {
        font-size: 1rem;
    }

    .topbar .d-flex {
        width: 100%;
        justify-content: space-between;
    }

    /* Reduce content padding */
    .content-area {
        padding: 1rem;
    }

    /* Stack cards */
    .row .col-md-6,
    .row .col-lg-3,
    .row .col-lg-4,
    .row .col-lg-6 {
        margin-bottom: 1rem;
    }
}

/* Mobile phones (< 768px) */
@media (max-width: 767.98px) {
    /* Hide desktop table, show card view */
    .table-responsive {
        display: none !important;
    }

    .mobile-card-view {
        display: block !important;
    }

    /* Forms - single column */
    .row .col-md-6 {
        margin-bottom: 1rem;
    }

    /* Larger form inputs */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Stack buttons */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Topbar adjustments */
    .topbar {
        padding: 0.75rem;
        padding-left: 3.5rem;
    }

    .topbar h5 {
        font-size: 0.95rem;
    }

    .topbar .text-muted {
        font-size: 0.875rem;
    }

    /* Tab navigation */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Stats cards */
    .stats-card {
        text-align: center;
    }

    .stats-card .stats-icon {
        font-size: 1.5rem;
    }

    /* Badges */
    .badge {
        display: block;
        margin-top: 0.25rem;
        width: fit-content;
    }

    /* Search box */
    .search-box input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Card headers */
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Login page adjustments */
    .login-card {
        margin: 1rem;
    }

    .login-header h3 {
        font-size: 1.25rem;
    }

    /* Sidebar adjustments for mobile */
    .sidebar {
        width: 280px;
    }

    .sidebar-brand {
        font-size: 1.25rem;
        padding: 0.75rem 1rem;
    }

    /* Toast positioning */
    .toast-container {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
    }

    .toast {
        min-width: 100%;
    }
}

/* Small phones (< 576px) */
@media (max-width: 575.98px) {
    .sidebar {
        width: 100%;
        max-width: 280px;
    }

    .content-area {
        padding: 0.75rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    /* Further reduce font sizes */
    body {
        font-size: 0.9rem;
    }

    h5 {
        font-size: 1rem;
    }

    /* Adjust button sizes */
    .btn-sm {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Landscape mode for tablets */
@media (min-width: 768px) and (max-width: 991.98px) and (orientation: landscape) {
    .sidebar {
        width: 220px;
    }

    .topbar {
        padding: 0.75rem 1.5rem;
        padding-left: 4rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase all interactive element sizes */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }

    .btn-sm {
        min-height: 38px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .table tbody tr:hover {
        background-color: transparent;
    }

    .sidebar-nav-link:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    /* Add active states instead */
    .table tbody tr:active {
        background-color: #f8f9fa;
    }

    .btn:active {
        transform: scale(0.98);
    }
}
