/* ============================================================
   MEILSYS - Design System
   Marine Electricals (India) Ltd.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Brand Colors - Marine Electricals Official */
    --me-navy: #0a1628;
    --me-royal: #2B3990;
    /* Official Blue */
    --me-blue: #1A3A6B;
    --me-blue-light: #4A5CAD;
    --me-red: #DA251D;
    /* Official Red */
    --me-accent: var(--me-red);
    --me-gold: #FFB300;
    --me-green: #10B981;

    /* Enterprise Neutrals */
    --bg-body: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    /* Very dark slate */
    --bg-sidebar-hover: #1E293B;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-light: #94A3B8;
    --border-color: #E2E8F0;

    /* Status Colors - Refined */
    --status-draft: #94A3B8;
    --status-submitted: #F59E0B;
    --status-approved: #10B981;
    --status-rejected: #EF4444;
    --status-present: #10B981;
    --status-absent: #EF4444;
    --status-half: #F59E0B;

    /* Spacing & Layout */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Premium Shadows - Multi-layered */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Login Page ── */
.login-page {
    background: radial-gradient(circle at top right, var(--me-royal), var(--me-navy));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(218, 37, 29, 0.1) 0%, transparent 70%);
    top: -200px;
    left: -200px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-xl);
    padding: 60px 48px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-logo {
    display: block;
    margin: 0 auto 32px;
    height: 70px;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h2 {
    font-weight: 800;
    color: var(--me-royal);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-floating>.form-control {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #f8fafc;
}

.form-floating>.form-control:focus {
    border-color: var(--me-royal);
    box-shadow: 0 0 0 4px rgba(43, 57, 144, 0.1);
}

.btn-login {
    background: linear-gradient(135deg, var(--me-royal) 0%, var(--me-blue-light) 100%);
    border: none;
    color: #fff;
    font-weight: 700;
    padding: 14px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    box-shadow: 0 10px 15px -3px rgba(43, 57, 144, 0.4);
    transition: all 0.3s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(43, 57, 144, 0.4);
    color: #fff;
}

/* ── Layout ── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: auto;
    width: auto;
    max-height: 50px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-label {
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 20px 12px 8px;
    opacity: 0.5;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    margin-bottom: 4px;
}

.nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--me-royal) 0%, var(--me-blue-light) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(43, 57, 144, 0.3);
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* ── Sidebar Footer Account Section (Premium V2) ── */
.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
}

.account-box {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-info-tray {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
}

.user-avatar-sm {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--me-royal) 0%, var(--me-blue-light) 100%);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-role-badge {
    font-size: 0.65rem;
    color: var(--me-gold);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-top: 4px;
    display: inline-block;
}

.logout-button-full {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    padding: 12px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.logout-button-full:hover {
    background: rgba(218, 37, 29, 0.15);
    color: #fff;
    border-color: rgba(218, 37, 29, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(218, 37, 29, 0.2);
}

.logout-button-full i {
    font-size: 1.1rem;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* ── Top Bar ── */
.topbar {
    height: var(--header-height);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar h4 {
    margin: 0;
    font-weight: 800;
    color: var(--me-royal);
    font-size: 1.25rem;
}

.live-clock {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    background: var(--bg-body);
    border-radius: var(--radius-xl);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xl);
    transition: all 0.2s;
}

.user-profile:hover {
    background: var(--bg-body);
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--me-royal) 0%, var(--me-blue-light) 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.topbar .page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar .live-clock {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.topbar .user-dropdown .btn {
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 6px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.topbar .user-dropdown .btn:hover {
    border-color: var(--me-blue-light);
    background: rgba(26, 58, 107, 0.04);
}

/* ── Page Content ── */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    background: var(--bg-card);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.95rem;
}

.card-body {
    padding: 20px;
}

/* ── Stat Cards ── */
.stat-card {
    border-radius: var(--radius-md);
    padding: 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.8;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 500;
    margin-top: 4px;
}

.stat-navy {
    background: linear-gradient(135deg, var(--me-navy), var(--me-royal));
}

.stat-blue {
    background: linear-gradient(135deg, var(--me-royal), var(--me-blue-light));
}

.stat-accent {
    background: linear-gradient(135deg, var(--me-red), #ff4d4d);
}

.stat-gold {
    background: linear-gradient(135deg, #e67e22, var(--me-gold));
}

.stat-green {
    background: linear-gradient(135deg, #059669, var(--me-green));
}

/* ── Status Badges ── */
.badge-draft {
    background: var(--status-draft);
}

.badge-submitted {
    background: var(--status-submitted);
    color: #000;
}

.badge-approved {
    background: var(--status-approved);
}

.badge-rejected {
    background: var(--status-rejected);
}

.badge-present {
    background: var(--status-present);
}

.badge-absent {
    background: var(--status-absent);
}

.badge-half_day {
    background: var(--status-half);
    color: #000;
}

.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    /* Default dark text for better visibility */
}

/* ── Navy Utilities (Custom) ── */
.text-navy {
    color: var(--me-navy) !important;
}

.bg-navy {
    background-color: var(--me-navy) !important;
    color: #fff;
}

.bg-navy-subtle {
    background-color: rgba(10, 22, 40, 0.08) !important;
}

.border-navy {
    border-color: var(--me-navy) !important;
}

/* ── Service Report Premium View (V2) ── */
.badge-service-premium {
    background: var(--me-royal);
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 6px rgba(10, 22, 40, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.view-label-sm {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
    display: block;
}

.view-value-md {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--me-navy);
}

.content-box-premium {
    background: #fff;
    border-left: 4px solid var(--me-royal);
    padding: 20px;
    border-radius: 0 8px 8px 0;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #444;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.card-view-premium {
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.card-view-premium .card-header {
    background: #f8f9fa !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    color: var(--me-navy) !important;
    font-size: 0.8rem !important;
    letter-spacing: 1.5px !important;
}

/* ── Tables ── */
.table {
    font-size: 0.88rem;
}

.table thead th {
    background: var(--bg-body);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border: none;
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table-hover tbody tr:hover {
    background: rgba(26, 58, 107, 0.03);
}

/* ── Buttons ── */
.btn {
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--me-blue);
    border-color: var(--me-blue);
}

.btn-primary:hover {
    background: var(--me-blue-light);
    border-color: var(--me-blue-light);
    transform: translateY(-1px);
}

.btn-success {
    border-radius: var(--radius-sm);
}

.btn-danger {
    border-radius: var(--radius-sm);
}

.btn-outline-primary:hover {
    background: var(--me-blue);
    border-color: var(--me-blue);
}

.btn-navy {
    background: linear-gradient(135deg, var(--me-navy) 0%, var(--me-royal) 100%);
    border: none;
    color: #fff !important;
    padding: 10px 24px;
    box-shadow: 0 4px 10px rgba(10, 22, 40, 0.25);
}

.btn-navy:hover {
    background: linear-gradient(135deg, var(--me-royal) 0%, var(--me-blue-light) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(10, 22, 40, 0.35);
    color: #fff !important;
}

.btn-outline-navy {
    color: var(--me-navy);
    border: 2px solid var(--me-navy);
    background: transparent;
}

.btn-outline-navy:hover {
    background: var(--me-navy);
    color: #fff !important;
}

.btn-enterprise {
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 800;
}

/* ── Forms ── */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--me-blue-light);
    box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.08);
}

.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
}

/* ── SR Form Sections ── */
.sr-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    overflow: hidden;
}

.sr-section-header {
    background: var(--me-navy);
    color: #fff;
    padding: 12px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sr-section-body {
    padding: 20px;
}

/* ── Flash Messages ── */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
    font-size: 0.88rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Dynamic Rows ── */
.dynamic-row {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Responsive ── */
.sidebar-toggle {
    display: none;
    background: var(--me-blue);
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .mobile-header {
        background: var(--bg-sidebar);
        padding: 12px 20px;
        display: flex;
        align-items: center;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        position: sticky;
        top: 0;
        z-index: 1001;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 999;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Scrollable nav pills utility */
    .nav-scrollable-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }

    .nav-scrollable-wrapper::-webkit-scrollbar {
        height: 2px;
    }

    .nav-scrollable-wrapper .nav-pills {
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .header-stack {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .header-stack .btn,
    .header-stack form {
        width: 100% !important;
    }
}

@media (max-width: 576px) {
    .page-content {
        padding: 16px;
    }

    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c5c9ce;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a5ab;
}

/* ── Print ── */
@media print {

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}