/* style.css - Modern Mobile-First + QR + Stats */

:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LOADING ===== */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
    color: var(--text-muted);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LAYOUT ===== */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span { color: var(--primary); }
.nav-tabs {
    display: flex;
    gap: 4px;
}
.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-tab:hover, .nav-tab.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
        var(--bg);
}

.login-card {
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 24px;
    padding: 48px 36px;
    width: 100%;
    max-width: 460px;
    text-align: center;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

.login-badge {
    display: inline-block;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 24px;
}

.login-card h1 {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.login-subtitle strong {
    color: #e2e8f0;
}

.login-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
    text-align: left;
}

.feature-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.login-footer {
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== DASHBOARD ===== */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.create-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
}
.create-box h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}
.form-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}
.form-group input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus {
    border-color: var(--primary);
}
.input-with-prefix {
    display: flex;
    align-items: stretch;
}
.input-with-prefix .prefix {
    background: #1e293b;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.input-with-prefix input {
    border-radius: 0 8px 8px 0;
    flex: 1;
}
.form-group small {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== URL LIST ===== */
.list-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}
.search-box input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
}

.table-wrapper {
    display: none;
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    background: rgba(15, 23, 42, 0.6);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(59, 130, 246, 0.05); }
.short-link {
    font-weight: 600;
    color: var(--primary);
}
.long-url {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.url-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.url-card .short-link {
    font-size: 1.05rem;
    margin-bottom: 6px;
    display: block;
}
.url-card .long-url {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    word-break: break-all;
    white-space: normal;
}
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal.hidden { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}
.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.2rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    z-index: 2000;
    box-shadow: var(--shadow);
    max-width: 90%;
    text-align: center;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.hidden { display: none; }

/* ===== QR CODE MODAL ===== */
.qr-modal-content {
    max-width: 420px;
    text-align: center;
}

.qr-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 8px;
}

.qrcode-container {
    background: #ffffff;
    padding: 16px;
    border-radius: 12px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-height: 240px;
    min-width: 240px;
}

.qrcode-container img,
.qrcode-container canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.qr-url {
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-all;
    max-width: 100%;
    line-height: 1.4;
}

.qr-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.qr-customize {
    width: 100%;
    text-align: left;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qr-customize .form-group {
    margin-bottom: 0;
}

.qr-customize input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
}

.qr-customize input[type="file"] {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.qr-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.qr-actions .btn {
    min-width: 130px;
}

/* ===== STATS PAGE ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.stats-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.stats-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.stats-table th,
.stats-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.stats-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
}

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

.badge-qr {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-normal {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.stats-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.stats-tab.active,
.stats-tab:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .form-row {
        flex-direction: row;
        align-items: flex-end;
    }
    .form-row .form-group { flex: 1; }
    .form-row .btn { flex-shrink: 0; height: 46px; }

    .table-wrapper { display: block; }
    .card-list { display: none; }
}

@media (max-width: 767px) {
    .header-inner {
        flex-wrap: wrap;
    }
    .nav-tabs {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }
    .user-info .user-name { display: none; }
}

@media (max-width: 480px) {
    .login-card {
        padding: 36px 24px;
    }
    .login-card h1 {
        font-size: 1.55rem;
    }
    .login-features {
        grid-template-columns: 1fr;
    }
}