/* =============================================================
   GSR600 – Lab 9 – Password Manager (Premium Redesign)
   Mobile-First Responsive Design
   ============================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* =============================================================
   Design Tokens
   ============================================================= */
:root {
    --bg-base: #0b0f19;
    --bg-surface: #111827;
    --bg-card: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --text-main: #ffffff;
    --text-muted: #cbd5e1;
    
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-accent: #0ea5e9;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Touch-friendly sizing */
    --touch-min: 44px;
    --sidebar-width: 280px;
    --topbar-height: 60px;
}

/* =============================================================
   Base / Reset – Mobile First
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* =============================================================
   Utilities
   ============================================================= */
.font-mono { font-family: var(--font-mono) !important; }
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-md);
}

/* Typography */
h1, h2, h3, h4, h5, h6 { font-weight: 700; color: #ffffff; letter-spacing: -0.025em; }
.text-muted { color: var(--text-muted) !important; }
.text-gradient {
    background: linear-gradient(135deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* =============================================================
   Forms – Touch-friendly (Mobile First)
   ============================================================= */
.form-control, .form-select {
    background-color: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    font-size: 1rem;
    min-height: var(--touch-min);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-accent) !important;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1) !important;
}
.form-control::placeholder { color: #94a3b8 !important; opacity: 1; }
.input-group-text {
    background-color: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    min-height: var(--touch-min);
}
.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #f8fafc;
    margin-bottom: 0.5rem;
}

/* Custom Switches – larger touch target */
.form-check-input:checked {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
}
.form-check-input {
    min-width: 2.5em;
    min-height: 1.25em;
}

/* =============================================================
   Buttons – Touch-friendly (Mobile First)
   ============================================================= */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.7rem 1.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: var(--transition);
    min-height: var(--touch-min);
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    -webkit-user-select: none;
    user-select: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}
.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
}
.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}
.btn-icon-only {
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}
.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* =============================================================
   Layout – Mobile First (column by default)
   ============================================================= */
.app-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    z-index: 1;
}

/* =============================================================
   Topbar – Mobile First
   ============================================================= */
.topbar {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1030;
    padding: 0.65rem 0;
    height: var(--topbar-height);
}
.topbar .container-fluid {
    height: 100%;
}
.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.brand-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--brand-accent), #34d399);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-base);
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Hamburger Button */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-min);
    height: var(--touch-min);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover, .hamburger-btn:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--brand-accent);
}

/* Topbar user info – hide name on very small screens */
.topbar-user-info .user-details { display: none; }

/* =============================================================
   Sidebar – Mobile First (Overlay on mobile)
   ============================================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1rem 2rem;
    -webkit-overflow-scrolling: touch;
}
.sidebar-wrapper.active {
    transform: translateX(0);
}

/* Sidebar header (mobile close button) */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}
.sidebar-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* Sidebar nav links */
.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 0.25rem;
    min-height: var(--touch-min);
    font-size: 0.95rem;
    -webkit-tap-highlight-color: transparent;
}
.nav-link-custom:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}
.nav-link-custom.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), transparent);
    color: var(--brand-accent);
    border-left: 3px solid var(--brand-accent);
}

/* =============================================================
   Main Content – Mobile First
   ============================================================= */
.main-content {
    flex-grow: 1;
    padding: 1.25rem 1rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* =============================================================
   Stats Cards – Mobile First (full width stacked)
   ============================================================= */
.stat-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: var(--transition);
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-icon.primary { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: #34d399; }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.stat-value { font-size: 1.35rem; font-weight: 800; color: #fff; line-height: 1; margin-bottom: 0.15rem; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* =============================================================
   Table – Mobile First (Card layout by default)
   ============================================================= */
.cred-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.cred-table { 
    width: 100%; 
    margin-bottom: 0; 
    color: var(--text-main); 
    background: transparent !important;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
}
.cred-table th, .cred-table td, .cred-table tr {
    background: transparent;
    color: inherit;
}

/* Mobile: card layout by default */
.cred-table thead { display: none; }
.cred-table tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}
.cred-table tbody tr:last-child { margin-bottom: 0; }
.cred-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    gap: 0.5rem;
    word-break: break-word;
}
.cred-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    flex-shrink: 0;
    min-width: 80px;
}
.cred-table td:last-child {
    border-bottom: 0;
    justify-content: flex-end;
}
.cred-table td:last-child::before {
    display: none;
}

/* Card actions — wider buttons on mobile */
.cred-table .d-inline-flex {
    gap: 0.5rem !important;
}

/* Badges */
.badge-custom {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    white-space: nowrap;
}

/* =============================================================
   Auth Cards – Mobile First
   ============================================================= */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--topbar-height));
    min-height: calc(100dvh - var(--topbar-height));
    padding: 1rem;
    background: radial-gradient(circle at center, #1e293b 0%, #0b0f19 70%);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2rem 1.5rem;
}

/* =============================================================
   Security Meter
   ============================================================= */
.security-meter-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.pwd-strength-meter {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.75rem 0;
}
.pwd-strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.4s ease, background-color 0.4s ease;
}

/* =============================================================
   Generator Display
   ============================================================= */
.gen-display {
    background: #0f172a;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    margin-bottom: 1.5rem;
    overflow-x: hidden;
}
.gen-password-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-accent);
    letter-spacing: 2px;
    word-break: break-all;
    overflow-wrap: anywhere;
}

/* =============================================================
   Hash output – prevent overflow
   ============================================================= */
.hash-output-display {
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.7;
    font-size: 0.8rem;
}

/* =============================================================
   Animations
   ============================================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

/* =============================================================
   SweetAlert2 mobile fix
   ============================================================= */
.swal2-popup {
    font-size: 0.95rem !important;
    max-width: calc(100vw - 2rem) !important;
}

/* =============================================================
   Responsive utility: prevent horizontal scroll
   ============================================================= */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* =============================================================
   ≥ 480px – Larger phones
   ============================================================= */
@media (min-width: 480px) {
    .topbar-user-info .user-details { display: flex; }

    .gen-password-text {
        font-size: 1.5rem;
        letter-spacing: 3px;
    }

    .auth-card {
        padding: 2.5rem 2rem;
    }
}

/* =============================================================
   ≥ 768px – Tablet
   ============================================================= */
@media (min-width: 768px) {
    .main-content {
        padding: 1.5rem 2rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .gen-password-text {
        font-size: 1.75rem;
    }
}

/* =============================================================
   ≥ 992px – Desktop: sidebar visible, no hamburger
   ============================================================= */
@media (min-width: 992px) {
    /* Hide hamburger */
    .hamburger-btn { display: none; }

    /* Layout becomes row */
    .app-container {
        flex-direction: row;
    }

    /* Sidebar – static in the flow, not overlay */
    .sidebar-overlay { display: none !important; }
    .sidebar-header { display: none; }

    .sidebar-wrapper {
        position: sticky;
        top: var(--topbar-height);
        left: 0;
        width: 260px;
        min-width: 260px;
        height: calc(100vh - var(--topbar-height));
        transform: translateX(0);
        z-index: 1;
        padding-top: 2rem;
        border-right: 1px solid var(--border-color);
        background: transparent;
    }
    /* Override the active class behavior on desktop */
    .sidebar-wrapper.active {
        transform: translateX(0);
    }

    /* Main content */
    .main-content {
        padding: 2rem;
        max-width: 1200px;
        margin: 0 auto;
    }

    /* Table: normal layout on desktop */
    .cred-table thead { display: table-header-group; }
    .cred-table tbody tr {
        display: table-row;
        margin-bottom: 0;
        background: none;
        border: none;
        border-radius: 0;
        padding: 0;
    }
    .cred-table th {
        background: rgba(15, 23, 42, 0.9);
        border-bottom: 1px solid var(--border-color);
        color: var(--text-muted);
        font-weight: 600;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        padding: 1rem 1.25rem;
    }
    .cred-table td {
        display: table-cell;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        vertical-align: middle;
    }
    .cred-table td::before { display: none; }
    .cred-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
    .cred-table tr:last-child td { border-bottom: none; }

    /* Stats */
    .stat-card {
        padding: 1.5rem;
    }
    .stat-card:hover {
        transform: translateY(-3px);
        border-color: rgba(255, 255, 255, 0.15);
        box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    }
    .stat-value { font-size: 1.5rem; }

    /* Buttons – hover effects on desktop only */
    .btn-primary:hover {
        transform: translateY(-2px);
    }
    .btn-icon-only:hover {
        transform: translateY(-2px);
    }

    /* Auth card */
    .auth-card {
        padding: 3rem 2.5rem;
    }

    /* Brand */
    .brand-logo {
        font-size: 1.25rem;
    }
    .brand-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    /* Gen display */
    .gen-password-text {
        font-size: 2rem;
    }
    .gen-display {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
}

/* =============================================================
   ≥ 1200px – Large desktop
   ============================================================= */
@media (min-width: 1200px) {
    .main-content {
        max-width: 1200px;
    }
}

/* =============================================================
   Accessibility: focus states
   ============================================================= */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.nav-link-custom:focus-visible,
.hamburger-btn:focus-visible,
.sidebar-close-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

/* Ensure no overflow from any child */
.main-content > * {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* =============================================================
   Prevent body scroll when sidebar overlay is open (mobile)
   ============================================================= */
body.sidebar-open {
    overflow: hidden;
}
