/* 
   MY STYLE - MODERN TECH THEME 
   Reset & Variables 
*/
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colors */
    --bg-main: #09090b;
    --bg-card: #18181b;
    --bg-hover: #27272a;
    --border: #3f3f46;

    --primary: #E50914;
    /* Keeping Netflix Red for identity */
    --primary-glow: rgba(229, 9, 20, 0.4);

    --text-main: #fafafa;
    --text-muted: #a1a1aa;

    --success: #10b981;
    --error: #f43f5e;

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-glow: 0 0 20px -5px var(--primary-glow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Utilities */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.text-center {
    text-align: center;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.brand-text {
    color: var(--primary);
}

/* Components: Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Components: Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    margin-bottom: 1.5rem;
}

.form-input,
.form-textarea {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Components: Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn.active-nav {
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.2) 0%, rgba(229, 9, 20, 0.05) 100%);
    border: 1px solid rgba(229, 9, 20, 0.5);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(229, 9, 20, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background: #b20710;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #3f3f46;
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--error);
}

.btn-danger:hover {
    background: rgba(244, 63, 94, 0.1);
    border-color: var(--error);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.sidebar-btn {
    justify-content: flex-start;
    width: 100%;
}

/* Specific: Index Page */
.hero-section {
    min-height: 100vh;
    display: flex;
    /* Changed to flex for better centering */
    align-items: center;
    justify-content: center;
    background: url('bg.jpg') no-repeat center center;
    background-size: cover;
    position: relative;
    padding: 1rem;
}

/* Ensure Hero Card and Result Card match widths */
.hero-card,
.result-card-container {
    width: 100%;
    max-width: 450px;
    /* Consistent max-width for both */
    margin: 0 auto;
}

.hero-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 2;
}

/* Admin Key Badge - Truncate and Styling */
.badge-key {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-family: monospace;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    cursor: copy;
    /* Changed to copy cursor */

    /* Truncation logic */
    display: inline-block;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    transition: all 0.2s;
}

.badge-key:hover {
    border-color: var(--success);
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.badge-key:active {
    transform: scale(0.98);
}

/* Email Result Content */
.email-content-box {
    background: #fff;
    color: #333;
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

/* Aggressive Reset for Email Content */
.email-content-box * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.email-content-box img {
    height: auto !important;
    display: block;
    margin: 0 auto;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    white-space: nowrap;
    /* PREVENT WRAPPING */
}

.badge-active {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.badge-expired {
    background: rgba(113, 113, 122, 0.1);
    color: #71717a;
    border: 1px solid rgba(113, 113, 122, 0.2);
}

.badge-log {
    padding: 2px 8px;
    /* Compact padding */
    border-radius: 4px;
    /* Less rounded, more tech-y */
    font-size: 0.65rem;
    /* Smaller font */
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-width: 1px;
    border-style: solid;
    display: inline-block;
}

.badge-count {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
    min-width: 30px;
    text-align: center;
}

.email-content-box table {
    width: 100% !important;
    display: block !important;
    /* Forces table to respect container width */
}

/* Specific: Admin Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    /* Increased spacing */
}

/* Table */
.table-container {
    background: #1c1c20;
    /* Slightly lighter than bg-card #18181b */
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    /* Limit height so it doesn't push content down */
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    left: 0;
    background: #27272a;
    /* Lighter header to distinguish */
}

.data-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    table-layout: fixed;
    /* Enforce strict column widths */
}

.data-table th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Fixed Column Widths (Total 100%) */
.data-table th:nth-child(1) {
    width: 20%;
}

/* Key */
.data-table th:nth-child(2) {
    width: 15%;
    padding-left: 0.5rem;
}

/* Buyer */

.data-table td:nth-child(2) {
    padding-left: 0.5rem !important;
}

/* Emails */
.data-table th:nth-child(3) {
    width: 32%;
}

/* Emails */

/* Emails */
.data-table th:nth-child(4) {
    width: 10%;
    text-align: center;
}

/* Total */
.data-table th:nth-child(5) {
    width: 10%;
}

/* Status */
.data-table th:nth-child(6) {
    width: 15%;
    text-align: right;
}

/* Aksi */

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    word-break: break-word;
    /* Safe to keep if table-layout is fixed */
}

/* CSS CLEANUP */

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table td:nth-child(5) {
    text-align: right;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-key {
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    /* Use the font we imported */
    font-size: 0.95rem;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;

    /* Truncation logic */
    display: inline-block;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    transition: all 0.2s;
    position: relative;
}

.badge-key::after {
    content: '\f0c5';
    /* FontAwesome Copy Icon */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge-key:hover {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(229, 9, 20, 0.3);
}

.badge-key:hover::after {
    opacity: 1;
    color: var(--primary);
}

.badge-key:active {
    transform: scale(0.98);
}

.tag-label {
    background: linear-gradient(135deg, var(--primary) 0%, #b20710 100%);
    color: white;
    font-size: 0.75rem;
    /* Smaller Font */
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    /* Smaller Box */
    border-radius: 4px;
    margin: 0;
    vertical-align: middle;
    box-shadow: 0 1px 5px rgba(229, 9, 20, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    display: inline-block;
    letter-spacing: 0px;

    /* ALLOW WRAPPING */
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.25;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    place-items: center;
    z-index: 100;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    /* Prevent modal from exceeding viewport height */
    overflow-y: auto;
    /* Enable vertical scrolling */
    padding: 2rem;
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem !important;
        /* Override inline padding */
    }

    .sidebar {
        /* Make sidebar visible and turn into top navigation */
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        position: static;
        height: auto;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        margin-bottom: 1rem;
    }

    .sidebar nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        margin-top: 1rem;
    }

    .sidebar nav .btn {
        flex: 1;
        justify-content: center !important;
        /* Override inline styling */
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    /* Adjust Main Content spacing */
    .main-content {
        gap: 2rem;
    }

    /* Table scrolling for tablets if not card view yet */
    .table-container {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .hero-card {
        margin: 0;
        width: 100%;
        padding: 1.5rem;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* Margin for Label Tag to separate from Key */
.tag-label {
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Ensure flex-col has gap */
.flex-col {
    gap: 0.5rem;
}