/**
 * Vandromeda Admin Dashboard Styles
 * Mobile-first responsive design
 */

/* ==========================================
   CSS Variables
   ========================================== */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --sidebar-bg: #1f2937;
    --sidebar-text: #9ca3af;
    --sidebar-active: #ffffff;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --input-border: #d1d5db;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --sidebar-width: 250px;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-color);
}

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

a:hover {
    text-decoration: underline;
}

/* ==========================================
   Layout
   ========================================== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--sidebar-active);
    margin: 0;
}

.sidebar-header span {
    font-size: 0.75rem;
    color: var(--sidebar-text);
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--sidebar-active);
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.nav-link.active {
    color: var(--sidebar-active);
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--primary-color);
}

.nav-link svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 1rem;
}

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    margin: -1rem -1rem 1rem -1rem;
}

.menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.menu-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

/* ==========================================
   Breadcrumb Navigation
   ========================================== */
.breadcrumb-nav {
    margin-bottom: 1rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
    content: '/';
    margin: 0 0.5rem;
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==========================================
   Section Sub-Navigation
   ========================================== */
.section-subnav {
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    padding: 0.25rem;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.subnav-list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: max-content;
}

.subnav-item {
    flex-shrink: 0;
}

.subnav-link {
    display: block;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.subnav-link:hover {
    color: var(--text-primary);
    background: var(--bg-color);
    text-decoration: none;
}

.subnav-link.active {
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
}

/* ==========================================
   Page Header
   ========================================== */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    width: 100%;
}

/* ==========================================
   Cards
   ========================================== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================
   Stats Grid
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.stat-icon.primary { background: rgba(79, 70, 229, 0.1); color: var(--primary-color); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.stat-icon.info { background: rgba(59, 130, 246, 0.1); color: var(--info-color); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-change.positive { color: var(--success-color); }
.stat-change.negative { color: var(--danger-color); }

/* ==========================================
   Tables
   ========================================== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-color);
    white-space: nowrap;
}

tr:hover {
    background: var(--bg-color);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

/* ==========================================
   Forms
   ========================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.form-inline .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

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

.form-error {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn svg {
    width: 1rem;
    height: 1rem;
}

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

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

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

.btn-secondary:hover {
    background: var(--bg-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

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

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

.btn-warning {
    background: var(--warning-color);
    color: white;
}

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
}

.btn-icon.btn-sm {
    padding: 0.25rem;
}

/* ==========================================
   Badges
   ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-radius: 9999px;
}

.badge-active,
.badge-succeeded,
.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-expired,
.badge-failed,
.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-inactive,
.badge-pending,
.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-revoked {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

.badge-refunded,
.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

/* ==========================================
   Pagination
   ========================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.pagination a:hover {
    background: var(--bg-color);
    text-decoration: none;
}

.pagination .active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .disabled {
    color: var(--text-muted);
    pointer-events: none;
}

/* ==========================================
   Alerts
   ========================================== */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ==========================================
   Modal
   ========================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem;
}

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

/* ==========================================
   Login Page
   ========================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

/* ==========================================
   Details List
   ========================================== */
.details-list {
    display: grid;
    gap: 0.75rem;
}

.details-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.details-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.details-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-all;
}

.details-value.mono {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.8125rem;
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* ==========================================
   Domain Tags
   ========================================== */
.domain-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.domain-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: monospace;
}

.domain-tag .remove {
    cursor: pointer;
    color: var(--text-muted);
}

.domain-tag .remove:hover {
    color: var(--danger-color);
}

/* ==========================================
   Empty State
   ========================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.empty-state h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ==========================================
   Utilities
   ========================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.w-full { width: 100%; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden { display: none !important; }

/* ==========================================
   Responsive - Tablet and up
   ========================================== */
@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   Responsive - Desktop
   ========================================== */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }

    .mobile-header {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: var(--sidebar-width);
        padding: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .details-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   Print Styles
   ========================================== */
@media print {
    .sidebar,
    .mobile-header,
    .btn,
    .pagination {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
