/* ============================================
   Wassili Admin Dashboard - Premium Modern Theme
   ============================================ */

:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: #4895ef;
    --accent: #4cc9f0;
    --success: #06d6a0;
    --warning: #ffd166;
    --danger: #ef476f;
    --dark: #2b2d42;
    --dark-2: #8d99ae;
    --light: #f8f9fa;
    --white: #ffffff;
    --sidebar-w: 280px;
    --radius: 20px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 15px 40px rgba(0, 0, 0, 0.12);
    --font-fam: 'Cairo', sans-serif;
}

body {
    font-family: var(--font-fam);
    background: #f1f5f9;
    direction: rtl;
    color: var(--dark);
    overflow-x: hidden;
}

/* --- Layout --- */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        transform: translateX(100%);
        z-index: 1060;
        /* Higher than overlay */
        overflow-y: auto;
        /* Enable scroll on mobile */
    }

    .sidebar.show {
        transform: translateX(0);
    }
}

/* --- Dedicated Sidebar Backdrop (mobile only) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    /* Simple dark dim, no blur */
    z-index: 1055;
    /* Between content and sidebar */
    cursor: pointer;
}

.sidebar-overlay.show {
    display: block;
}

.sidebar-brand {
    padding: 30px 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.2);
}

.sidebar-brand .logo {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 15px;
    backdrop-filter: blur(10px);
}

.sidebar-brand h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
}

.sidebar-brand p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 15px;
}

.sidebar-nav .nav-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--dark-2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 20px 0 10px;
    padding: 0 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 18px;
    color: var(--dark);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    width: 100%;
    margin-bottom: 5px;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(67, 97, 238, 0.05);
    color: var(--primary);
    transform: translateX(-5px);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

.nav-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
}

.logout-btn {
    width: 100%;
    background: rgba(239, 71, 111, 0.1);
    color: var(--danger);
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.logout-btn:hover {
    background: var(--danger);
    color: var(--white);
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    min-width: 0;
    /* Important for flex-shrink */
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.top-header {
    background: var(--white);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.header-title h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    color: var(--dark);
}

.header-title p {
    font-size: 0.85rem;
    color: var(--dark-2);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--dark);
    cursor: pointer;
}

@media (max-width: 991.98px) {
    .menu-toggle {
        display: block;
    }

    .top-header {
        padding: 15px 20px;
    }
}

.content-body {
    padding: 30px;
}

@media (max-width: 767.98px) {
    .content-body {
        padding: 20px 15px;
    }
}

/* --- Stats Cards --- */
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
    position: relative;
    z-index: 2;
}

.bg-grad-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.bg-grad-success {
    background: linear-gradient(135deg, var(--success), #2a9d8f);
}

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

.bg-grad-danger {
    background: linear-gradient(135deg, var(--danger), #e07a5f);
}

.stat-info {
    flex-grow: 1;
    z-index: 2;
}

.stat-info h5 {
    font-size: 0.85rem;
    color: var(--dark-2);
    font-weight: 700;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.stat-info h2 {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--dark);
    margin: 0;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.05;
    z-index: 0;
}

/* --- Section Cards --- */
.section-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f5f9;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title i {
    width: 36px;
    height: 36px;
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* --- Buttons --- */
.btn-custom {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    color: var(--white);
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
}

.btn-success-custom {
    background: linear-gradient(135deg, var(--success), #2a9d8f);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(6, 214, 160, 0.3);
}

.btn-success-custom:hover {
    transform: translateY(-2px);
    color: var(--white);
}

.btn-warning-custom {
    background: linear-gradient(135deg, var(--warning), #f4a261);
    color: var(--dark);
    box-shadow: 0 4px 15px rgba(255, 209, 102, 0.3);
}

.btn-warning-custom:hover {
    transform: translateY(-2px);
    color: var(--dark);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-icon.edit {
    background: rgba(255, 209, 102, 0.2);
    color: #d4a373;
}

.btn-icon.edit:hover {
    background: var(--warning);
    color: var(--dark);
    transform: scale(1.05);
}

.btn-icon.delete {
    background: rgba(239, 71, 111, 0.2);
    color: var(--danger);
}

.btn-icon.delete:hover {
    background: var(--danger);
    color: var(--white);
    transform: scale(1.05);
}

.btn-icon.toggle-on {
    background: rgba(6, 214, 160, 0.2);
    color: var(--success);
}

.btn-icon.toggle-on:hover {
    background: var(--success);
    color: var(--white);
    transform: scale(1.05);
}

.btn-icon.toggle-off {
    background: rgba(239, 71, 111, 0.2);
    color: var(--danger);
}

.btn-icon.toggle-off:hover {
    background: var(--danger);
    color: var(--white);
    transform: scale(1.05);
}

/* --- Tables (DataTables Overrides) --- */
.dataTables_wrapper {
    padding: 0 !important;
}

table.dataTable {
    border-collapse: collapse !important;
    width: 100% !important;
    margin-top: 15px !important;
    margin-bottom: 15px !important;
}

table.dataTable thead th {
    background: #f8f9fa;
    color: var(--dark-2);
    font-weight: 700;
    padding: 15px !important;
    border-bottom: 2px solid #e9ecef !important;
    font-size: 0.85rem;
    text-transform: uppercase;
}

table.dataTable tbody td {
    padding: 15px !important;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9 !important;
    font-size: 0.95rem;
    color: var(--dark);
}

table.dataTable tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.02) !important;
}

.dataTables_filter input {
    border: 2px solid #e9ecef !important;
    border-radius: 10px !important;
    padding: 8px 15px !important;
    font-family: inherit !important;
    transition: border-color 0.2s;
}

.dataTables_filter input:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: none !important;
}

.dataTables_length select {
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    padding: 6px 30px 6px 15px !important;
}

/* --- Badges --- */
.badge-custom {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-success {
    background: rgba(6, 214, 160, 0.15);
    color: #059b73;
}

.badge-danger {
    background: rgba(239, 71, 111, 0.15);
    color: #c9184a;
}

.badge-warning {
    background: rgba(255, 209, 102, 0.2);
    color: #d4a373;
}

.badge-info {
    background: rgba(76, 201, 240, 0.15);
    color: #0077b6;
}

.badge-primary {
    background: rgba(67, 97, 238, 0.15);
    color: var(--primary);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(43, 45, 66, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: var(--white);
    border-radius: 24px;
    padding: 35px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.modal-overlay.show .modal-box {
    transform: scale(1) translateY(0);
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark-2);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--danger);
    color: var(--white);
    transform: rotate(90deg);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 25px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-title i {
    color: var(--primary);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    font-weight: 700;
    color: var(--dark-2);
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: block;
}

.form-control,
.form-select {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8f9fa;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
    background: var(--white);
    outline: none;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* --- Notifications Pills --- */
.target-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.target-pill {
    padding: 10px 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: var(--white);
    color: var(--dark-2);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.target-pill:hover {
    border-color: var(--primary-light);
}

.target-pill.active {
    background: rgba(67, 97, 238, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.target-pill input[type="radio"] {
    display: none;
}

/* --- Section Visibility --- */
.dashboard-section {
    display: none;
    animation: fadeIn 0.4s;
}

.dashboard-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Pending Captains Cards --- */
.captain-card {
    background: var(--white);
    border: 1px solid #e9ecef;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    transition: all 0.2s;
}

.captain-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.captain-avatar {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.captain-info-wrap {
    flex-grow: 1;
}

.captain-info-wrap h4 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0 0 5px;
    color: var(--dark);
}

.captain-info-wrap p {
    font-size: 0.85rem;
    color: var(--dark-2);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.captain-actions {
    display: flex;
    gap: 10px;
}

/* --- Utilities --- */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--primary);
}

.loading-spinner i {
    font-size: 2rem;
    margin-bottom: 15px;
}

.loading-spinner p {
    font-weight: 700;
    color: var(--dark-2);
}