/* =========================================
   VoucherReset - Dark Theme Styles
   ========================================= */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a3e;
    --bg-card-hover: #222255;
    --bg-input: #0f0f2a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent-primary: #6c5ce7;
    --accent-secondary: #a855f7;
    --gradient-start: #6c5ce7;
    --gradient-end: #e74c6c;
    --success: #00d68f;
    --warning: #f5a623;
    --danger: #ff4757;
    --border-color: #2a2a4e;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

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

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

.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}

main {
    flex: 1;
    padding: 24px 0 48px;
}

/* ---- Header ---- */
.app-header {
    padding: 24px 0;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.app-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.app-header .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.app-header .brand-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.app-header .brand-text span {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header .tagline {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

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

.app-footer a {
    color: var(--accent-secondary);
    text-decoration: none;
}

/* ---- Section Headings ---- */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ---- Router Select Dropdown ---- */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 14px 16px;
    padding-right: 80px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.select-wrapper select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.select-wrapper select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px;
}

.select-status {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 6px;
}

.select-status.visible {
    display: flex;
}

.select-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.select-status .status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(0, 214, 143, 0.5);
}

.select-status .status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(255, 71, 87, 0.3);
}

.select-status .status-dot.checking {
    background: var(--text-muted);
    animation: pulse-dot 1.2s infinite;
}

.select-status .status-text {
    color: var(--text-muted);
}

.select-status .status-text.online {
    color: var(--success);
}

.select-status .status-text.offline {
    color: var(--danger);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}

/* ---- Voucher Form ---- */

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

.voucher-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

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

.form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #fff;
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(108, 92, 231, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

/* ---- Result Messages ---- */
.result-wrapper {
    display: none;
    animation: slideDown 0.3s ease;
}

.result-wrapper.visible {
    display: block;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.result-card .result-icon {
    font-size: 56px;
    margin-bottom: 16px;
    line-height: 1;
}

.result-card .result-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-card .result-message {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.5;
}

.result-card.result-success .result-title { color: var(--success); }
.result-card.result-expired .result-title { color: var(--danger); }
.result-card.result-not_found .result-title { color: var(--warning); }
.result-card.result-error .result-title { color: var(--danger); }

.result-card.result-success { border-color: rgba(0, 214, 143, 0.3); }
.result-card.result-expired { border-color: rgba(255, 71, 87, 0.3); }
.result-card.result-not_found { border-color: rgba(245, 166, 35, 0.3); }
.result-card.result-error { border-color: rgba(255, 71, 87, 0.3); }

/* ---- Loading Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- Admin Styles ---- */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.admin-header h2 {
    font-size: 20px;
    font-weight: 700;
}

/* Admin Login */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 36px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 20px;
}

.login-card .error-msg {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* Admin Table */
.admin-container {
    max-width: 960px;
}

.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrapper th,
.table-wrapper td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table-wrapper th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table-wrapper tr:last-child td {
    border-bottom: none;
}

.table-wrapper tr:hover td {
    background: rgba(108, 92, 231, 0.04);
}

.table-wrapper .actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    width: auto;
}

.btn-edit {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.btn-edit:hover {
    background: rgba(108, 92, 231, 0.25);
}

.btn-delete {
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-delete:hover {
    background: rgba(255, 71, 87, 0.2);
}

.btn-add {
    background: rgba(0, 214, 143, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 214, 143, 0.3);
    width: auto;
    padding: 10px 20px;
}

.btn-add:hover {
    background: rgba(0, 214, 143, 0.25);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    width: auto;
    padding: 10px 20px;
    font-size: 13px;
}

.btn-logout:hover {
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    border-color: rgba(255, 71, 87, 0.3);
}

/* Admin Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 28px 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.2s ease;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal .form-actions .btn {
    flex: 1;
}

.password-masked {
    font-family: monospace;
    color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .router-grid {
        grid-template-columns: 1fr;
    }

    .voucher-card {
        padding: 20px 16px;
    }

    .result-card {
        padding: 32px 16px;
    }

    .table-wrapper {
        overflow-x: auto;
    }

    .table-wrapper table {
        min-width: 600px;
    }

    .modal .form-row {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-header .btn {
        width: 100%;
    }
}

/* ---- Utility ---- */
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
