/* ==========================================================================
   Netflix Code Reader - Modern & Clean Dark Theme Styling
   ========================================================================== */

:root {
    --bg-main: #141414;
    --bg-card: #1f1f1f;
    --bg-card-secondary: #27272a;
    --bg-input: #18181b;
    --bg-table-row: #1e1e1e;
    --bg-table-hover: #262626;
    
    --netflix-red: #E50914;
    --netflix-red-hover: #f40612;
    --netflix-red-glow: rgba(229, 9, 20, 0.4);
    
    --accent-blue: #0284c7;
    --accent-blue-hover: #0369a1;
    --accent-green: #10b981;
    --accent-green-hover: #059669;
    --accent-danger: #ef4444;
    --accent-danger-hover: #dc2626;

    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #333338;
    --border-subtle: #27272a;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(229, 9, 20, 0.25);
    --transition: all 0.2s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Background ambient light */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 350px;
    background: radial-gradient(circle, rgba(229, 9, 20, 0.12) 0%, rgba(20, 20, 20, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.header-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brand-netflix {
    font-size: 26px;
    font-weight: 800;
    color: var(--netflix-red);
    letter-spacing: 1.5px;
    text-shadow: 0 0 20px var(--netflix-red-glow);
}

.brand-sub {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.header-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    color: #34d399;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 10px #34d399;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(229, 9, 20, 0.3);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-title svg {
    color: var(--netflix-red);
}

/* ==========================================================================
   Input Form
   ========================================================================== */
.input-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 280px;
    position: relative;
    display: flex;
    align-items: center;
}

.input-group input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 44px 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--netflix-red);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.2);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Action Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--netflix-red);
    color: white;
    box-shadow: 0 4px 14px rgba(229, 9, 20, 0.35);
}

.btn-primary:hover {
    background-color: var(--netflix-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(229, 9, 20, 0.45);
}

.btn-secondary {
    background-color: var(--bg-card-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #38383e;
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
}

.btn-view {
    background-color: var(--accent-blue);
    color: white;
}

.btn-view:hover {
    background-color: var(--accent-blue-hover);
    transform: translateY(-1px);
}

.btn-delete {
    background-color: var(--accent-danger);
    color: white;
}

.btn-delete:hover {
    background-color: var(--accent-danger-hover);
    transform: translateY(-1px);
}

/* ==========================================================================
   Controls Bar & Toggles
   ========================================================================== */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-control input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background-color: var(--border-color);
    border-radius: var(--radius-full);
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-control input:checked + .toggle-slider {
    background-color: var(--netflix-red);
}

.toggle-control input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

/* Recent History */
.recent-history {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.history-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.history-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    background: var(--bg-card-secondary);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background: #333338;
    color: white;
    border-color: var(--netflix-red);
}

.clear-history-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.clear-history-btn:hover {
    color: var(--accent-danger);
}

/* ==========================================================================
   Quick OTP Hero Box
   ========================================================================== */
.quick-otp-card {
    background: linear-gradient(145deg, #241618 0%, #1a1a1e 100%);
    border: 1.5px solid rgba(229, 9, 20, 0.4);
    box-shadow: var(--shadow-glow);
    animation: fadeIn 0.3s ease;
}

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

.quick-otp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #ff4d58;
    letter-spacing: 1px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--netflix-red);
    border-radius: 50%;
    animation: pulse 1.2s infinite;
}

.otp-time {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: monospace;
}

.quick-otp-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.otp-display-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed rgba(229, 9, 20, 0.5);
    border-radius: var(--radius-md);
    padding: 16px 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.otp-code {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 6px;
    color: #ffffff;
    font-family: 'Courier New', Courier, monospace;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.btn-copy {
    background-color: var(--accent-green);
    color: white;
    padding: 10px 20px;
    font-size: 14px;
}

.btn-copy:hover {
    background-color: var(--accent-green-hover);
    transform: translateY(-1px);
}

.otp-note {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==========================================================================
   Table Section (Khớp hoàn toàn với hình mẫu của bạn)
   ========================================================================== */
.table-card {
    padding: 0;
    overflow: hidden;
    background-color: #1a1a1a;
}

.table-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: #1a1a1a;
    border-bottom: 1px solid var(--border-color);
}

.table-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-title h3 {
    font-size: 15px;
    font-weight: 600;
}

.email-badge {
    background: rgba(229, 9, 20, 0.15);
    color: #ff6b72;
    border: 1px solid rgba(229, 9, 20, 0.3);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-family: monospace;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.email-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.email-table th {
    background-color: #171717;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.email-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #282828;
    font-size: 14px;
    vertical-align: middle;
}

.email-row {
    background-color: var(--bg-table-row);
    transition: var(--transition);
}

.email-row:hover {
    background-color: var(--bg-table-hover);
}

.sender-cell {
    font-weight: 700;
    color: #ffffff;
    font-size: 15px;
    white-space: nowrap;
}

.subject-cell {
    color: #ffffff;
}

.subject-title {
    font-weight: 600;
    color: #ffffff;
    font-size: 14px;
}

/* OTP Pill y như ảnh */
.otp-pill {
    display: inline-flex;
    align-items: center;
    background-color: #132e27;
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.25);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 5px;
    letter-spacing: 0.5px;
}

.time-cell {
    color: #a1a1aa;
    font-family: monospace;
    font-size: 13px;
    white-space: nowrap;
}

.actions-td {
    text-align: center;
}

.actions-cell {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state p {
    font-size: 14px;
    max-width: 440px;
}

.loading-state {
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(229, 9, 20, 0.2);
    border-top-color: var(--netflix-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Detail Modal
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.modal-meta {
    padding: 12px 24px;
    background: var(--bg-card-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 24px;
    font-size: 13px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    gap: 6px;
}

.meta-label {
    color: var(--text-muted);
}

.meta-value {
    color: var(--text-primary);
    font-weight: 500;
}

.modal-otp-box {
    margin: 16px 24px 0 24px;
    padding: 14px 20px;
    background: rgba(229, 9, 20, 0.1);
    border: 1.5px solid rgba(229, 9, 20, 0.4);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-otp-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ff5252;
}

.modal-otp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-otp-code {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 4px;
    color: #ffffff;
    font-family: monospace;
}

.modal-body {
    padding: 18px 24px;
    overflow-y: auto;
    flex: 1;
}

.email-content-view {
    background: #ffffff;
    color: #18181b;
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    max-height: 380px;
    overflow-y: auto;
    word-break: break-word;
}

.email-content-view img {
    max-width: 100%;
    height: auto;
}

.modal-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #10b981;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 2000;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--accent-danger);
}

.toast-icon {
    font-weight: bold;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
    margin-top: auto;
    padding-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    .app-container {
        padding: 16px 12px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .input-form {
        flex-direction: column;
    }

    .btn-primary {
        width: 100%;
    }

    .otp-display-wrap {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-copy {
        width: 100%;
    }

    .email-table th, .email-table td {
        padding: 12px 10px;
        font-size: 13px;
    }

    .actions-cell {
        flex-direction: column;
        gap: 4px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 11px;
    }
}
