/**
 * Private URL Shortener - Admin Panel Lightweight CSS
 * Zero heavy frameworks. Clean, modern, accessible, responsive.
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation Header */
.top-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.05rem;
}

.brand-badge {
    font-size: 1.2rem;
}

.private-badge {
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.nav-item:hover {
    color: var(--text-main);
    background: #f1f5f9;
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Main Content Area */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
}

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

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.page-header-actions {
    display: flex;
    gap: 8px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-badge {
    font-size: 0.75rem;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 12px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.metric-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.metric-card-success .metric-value { color: var(--success); }
.metric-card-warning .metric-value { color: var(--warning); }
.metric-card-info .metric-value { color: var(--primary); }
.metric-card-highlight { background: #eff6ff; border-color: #bfdbfe; }
.metric-card-highlight .metric-value { color: #1d4ed8; }

/* Dashboard Split Grid */
.dashboard-split-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background: #fcfdfe;
}

.data-table tr.row-disabled {
    background: #fafafa;
    opacity: 0.75;
}

/* Cells */
.short-url-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.short-code-link {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.short-code-link:hover {
    text-decoration: underline;
}

.destination-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 380px;
}

.destination-text {
    color: #334155;
    word-break: break-all;
    font-size: 0.825rem;
}

.link-title-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #0f172a;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #1e293b;
}

.btn-outline {
    background: #ffffff;
    border-color: var(--border-color);
    color: #334155;
}

.btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.btn-warning:hover {
    background: #fde68a;
}

.btn-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-copy-icon, .btn-copy-icon-sm {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 0.75rem;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s;
}

.btn-copy-icon:hover, .btn-copy-icon-sm:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.inline-form {
    display: inline;
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-outline { border: 1px solid var(--border-color); color: #475569; background: #ffffff; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-label.required::after {
    content: " *";
    color: var(--danger);
}

.form-label-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-col {
    flex: 1;
    margin-bottom: 0;
}

.form-row-compact {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-col-wide { flex: 2; }
.form-col-narrow { flex: 1.2; }
.form-col-action { flex: 0 0 auto; }

.input-prefix-wrapper {
    display: flex;
    align-items: center;
}

.input-prefix {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 6px 0 0 6px;
    padding: 9px 10px;
    font-size: 0.825rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.input-prefix-wrapper .form-control {
    border-radius: 0 6px 6px 0;
}

.quick-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

/* Feature Toggle Card */
.feature-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 14px 16px;
}

.toggle-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 2px;
}

.toggle-desc {
    font-size: 0.8rem;
    color: #64748b;
    max-width: 650px;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .2s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.alert-success { background: var(--success-light); border: 1px solid #bbf7d0; color: #166534; }
.alert-danger { background: var(--danger-light); border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-light); border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: var(--primary-light); border: 1px solid #bfdbfe; color: #1e40af; }

/* Filter form */
.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-col { flex: 2; min-width: 200px; }
.filter-col { flex: 1; min-width: 140px; }
.filter-col-sm { width: 120px; }
.filter-actions { display: flex; gap: 6px; }

/* Bulk Toolbar */
.bulk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.bulk-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Top Links Widget */
.top-links-list {
    list-style: none;
}

.top-link-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-link-code {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    display: block;
}

.top-link-dest {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Tabs */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    border-radius: 8px 8px 0 0;
}

.tab-item {
    padding: 12px 20px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Chart */
.chart-container {
    padding: 16px 0;
}

.bar-chart-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 24px;
}

.bar-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.bar-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.bar-track {
    flex: 1;
    width: 100%;
    max-width: 36px;
    background: #f1f5f9;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
}

.bar-fill {
    width: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: height 0.3s ease;
}

.bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: nowrap;
}

/* Login View */
.login-body {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.login-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
}

.login-header p {
    font-size: 0.85rem;
    color: #64748b;
}

.password-wrapper {
    position: relative;
}

.btn-toggle-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    color: #64748b;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #94a3b8;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Footer */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 16px 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.p-0 { padding: 0 !important; }
.border-top-0 { border-top: none !important; border-top-left-radius: 0 !important; border-top-right-radius: 0 !important; }

/* Responsive reflow */
@media (max-width: 900px) {
    .dashboard-split-grid {
        grid-template-columns: 1fr;
    }
    .form-row-compact {
        flex-direction: column;
        align-items: stretch;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (max-width: 640px) {
    .nav-container {
        height: auto;
        padding: 10px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    .nav-menu {
        flex-wrap: wrap;
        width: 100%;
        margin: 6px 0;
    }
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }
    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        display: none;
    }
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .search-col, .filter-col, .filter-col-sm {
        width: 100%;
    }
}
