/* BillShare - Modern Dark Mode UI */
/* Inspired by Credor³ but cleaner and more professional */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Colors - Jellyseerr Style */
    --color-primary: #a855f7;
    --color-primary-dark: #9333ea;
    --color-primary-light: #c084fc;
    --color-secondary: #6366f1;
    --color-danger: #f43f5e;
    --color-warning: #fb923c;
    --color-info: #06b6d4;
    --color-success: #10b981;
    
    /* Backgrounds - Jellyseerr Dark */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-hover: #374151;
    --bg-elevated: #1f2937;
    --bg-card: #1f2937;
    --bg-sidebar: #111827;
    
    /* Text */
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Borders & Effects */
    --border-color: rgba(75, 85, 99, 0.4);
    --border-color-hover: rgba(168, 85, 247, 0.4);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(168, 85, 247, 0.2);
    
    /* Layout */
    --sidebar-width: 240px;
    --topbar-height: 64px;
    --max-width: 1400px;
    --spacing: 1.5rem;
    
    /* Animation */
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: 
        radial-gradient(circle at 20% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-right: 1px solid rgba(75, 85, 99, 0.3);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.3);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand .brand-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, #ec4899 100%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.sidebar-brand .brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: var(--transition);
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(168, 85, 247, 0.1);
}

.sidebar-link.active {
    color: white;
    background: var(--color-primary);
}

.sidebar-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.user-avatar {
    font-size: 1.25rem;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: rgba(31, 41, 55, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}

.topbar-content {
    height: 100%;
    padding: 0 var(--spacing);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 9999px;
    padding: 0.5rem 1rem;
    flex: 1;
    max-width: 400px;
    transition: var(--transition);
}

.search-box:focus-within {
    background: rgba(17, 24, 39, 0.8);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.search-icon {
    color: var(--text-muted);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-balance {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.9) 0%, rgba(147, 51, 234, 0.9) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 12px rgba(168, 85, 247, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-color-hover);
}

/* Main Content */
.main {
    flex: 1;
    padding: var(--spacing);
    width: 100%;
    max-width: var(--max-width);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
}

.btn:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: white; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-warning { background: var(--color-warning); color: white; }
.btn-info { background: var(--color-info); color: white; }
.btn-success { background: var(--color-success); color: white; }

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

/* Forms */
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Section */
.section {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.section:hover {
    background: rgba(31, 41, 55, 0.75);
    border-color: rgba(75, 85, 99, 0.5);
}

.section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: var(--border-radius);
    margin: 2rem 0;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.empty-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: rgba(168, 85, 247, 0.4);
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.15), 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

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

/* Subscriptions */
.subscriptions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.subscription-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: all 0.2s;
}

.subscription-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
}

.subscription-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.subscription-cost {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 1rem;
    font-weight: 700;
}

.subscription-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.subscription-info .description {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

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

/* Transactions */
.transactions-list,
.transactions-table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.transaction-item:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.transaction-info {
    flex: 1;
}

.transaction-type {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.transaction-date,
.transaction-subscription,
.transaction-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.transaction-amount {
    font-size: 1.25rem;
    font-weight: 700;
}

.transaction-amount.positive {
    color: var(--color-success);
}

.transaction-amount.negative {
    color: var(--color-danger);
}

/* Admin */
/* Admin Page */
.admin-info-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(99, 102, 241, 0.1) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: var(--border-radius);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.info-value {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.admin-sections {
    display: grid;
    gap: 2rem;
}

.admin-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.admin-card h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.users-table,
.stat-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.user-info {
    flex: 1;
}

.user-email {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.user-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-row {
    flex-direction: row;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.stat-row strong {
    color: var(--color-primary);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--color-success);
    color: var(--color-success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.active {
    display: flex;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.modal form {
    padding: 1.5rem;
}

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

/* Toast */
#toast-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-color: var(--color-success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.toast-error {
    border-color: var(--color-danger);
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.toast-info {
    border-color: var(--color-info);
    background: rgba(6, 182, 212, 0.1);
    color: var(--color-info);
}

/* Loading */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 2rem;
}

.login-card {
    background: rgba(31, 41, 55, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 40px rgba(168, 85, 247, 0.1);
}

.login-card::before {
    display: none;
}

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

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-buttons .btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
}

.login-buttons .btn-primary {
    background: var(--color-primary);
    border: none;
}

.login-buttons .btn-primary:hover {
    background: var(--color-primary-dark);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    :root {
        --spacing: 1rem;
    }

    .header-content {
        flex-direction: column;
        padding: 1rem;
        height: auto;
        gap: 1rem;
    }

    .nav {
        width: 100%;
        justify-content: space-around;
        order: 3;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .user-menu {
        order: 2;
        width: 100%;
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .subscriptions-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 1rem;
    }

    #toast-container {
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
    }
}

/* Dark scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}
