/* TubeTax Admin - Stripe Dashboard Style */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #635BFF;
    --primary-dark: #5851DB;
    --bg-dark: #0A2540;
    --bg-light: #F6F9FC;
    --text-primary: #0A2540;
    --text-secondary: #425466;
    --text-muted: #8898AA;
    --border: #E6EBF1;
    --success: #00D4AA;
    --warning: #FFB800;
    --error: #FF5C5C;
    --sidebar-width: 240px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Login Screen */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a365d 100%);
}

.login-card {
    background: white;
    padding: 48px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.login-logo {
    margin-bottom: 24px;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-card > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.google-btn:hover {
    background: var(--bg-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-note {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header span {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
}

.user-info span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.logout-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
    fill: rgba(255, 255, 255, 0.7);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

/* Page */
.page {
    max-width: 1200px;
}

.page-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
}

.page-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.stat-icon.users {
    background: linear-gradient(135deg, #635BFF, #8B5CF6);
}

.stat-icon.transactions {
    background: linear-gradient(135deg, #00D4AA, #10B981);
}

.stat-icon.new-users {
    background: linear-gradient(135deg, #FFB800, #F59E0B);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-light);
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.btn-icon:hover {
    background: var(--bg-light);
}

/* Select Input */
.select-input {
    padding: 10px 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-light);
}

.data-table td {
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: var(--bg-light);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-cell img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border);
}

.user-cell span {
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-success {
    background: rgba(0, 212, 170, 0.1);
    color: #00A67E;
}

.badge-warning {
    background: rgba(255, 184, 0, 0.1);
    color: #D97706;
}

.view-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 37, 64, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.user-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.user-detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
}

.user-detail-info {
    flex: 1;
}

.user-detail-info h3 {
    font-size: 18px;
    font-weight: 600;
}

.user-detail-info p {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.transactions-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.transactions-list {
    max-height: 400px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.transaction-info {
    display: flex;
    flex-direction: column;
}

.transaction-desc {
    font-weight: 500;
    margin-bottom: 4px;
}

.transaction-date {
    font-size: 12px;
    color: var(--text-muted);
}

.transaction-amount {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.transaction-amount.positive {
    color: var(--success);
}

.transaction-amount.negative {
    color: var(--error);
}

/* Code Viewer */
.code-viewer {
    display: flex;
    gap: 24px;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.file-tree {
    width: 280px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-tree-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.file-tree-header svg {
    width: 20px;
    height: 20px;
    fill: var(--primary);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.file-item:hover {
    background: var(--bg-light);
}

.file-item.active {
    background: rgba(99, 91, 255, 0.1);
    color: var(--primary);
}

.file-item svg {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}

.file-item.active svg {
    fill: var(--primary);
}

.file-item.directory {
    font-weight: 500;
    color: var(--text-secondary);
}

.code-content {
    flex: 1;
    background: #1e1e1e;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #2d2d2d;
    color: #aaa;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.code-header .btn-icon {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.2);
}

.code-header .btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.code-header .btn-icon svg {
    fill: #aaa;
}

.code-block {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 20px;
    font-size: 13px;
    line-height: 1.6;
    background: #1e1e1e !important;
}

.code-block code {
    font-family: 'JetBrains Mono', monospace;
}

/* Logs */
.logs-container {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.logs-list {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.log-item {
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.log-item:last-child {
    border-bottom: none;
}

.log-timestamp {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.log-severity {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.log-severity.error {
    background: rgba(255, 92, 92, 0.1);
    color: var(--error);
}

.log-severity.warning {
    background: rgba(255, 184, 0, 0.1);
    color: var(--warning);
}

.log-severity.info {
    background: rgba(99, 91, 255, 0.1);
    color: var(--primary);
}

.log-severity.debug {
    background: rgba(136, 152, 170, 0.1);
    color: var(--text-muted);
}

.log-message {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-word;
}

/* Loading Spinner */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

.loading-cell {
    text-align: center;
    padding: 40px !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Recent Activity */
.recent-section {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 24px;
}

.recent-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.activity-list {
    min-height: 200px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-icon svg {
    width: 20px;
    height: 20px;
    fill: var(--text-muted);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    margin-bottom: 2px;
}

.activity-time {
    font-size: 13px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header span,
    .nav-item span:not(.nav-item svg),
    .user-info span {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 70px;
    }

    .code-viewer {
        flex-direction: column;
        height: auto;
    }

    .file-tree {
        width: 100%;
        max-height: 300px;
    }

    .code-content {
        min-height: 400px;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: var(--border);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Database Page */
.database-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.db-tab {
    padding: 10px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.db-tab:hover {
    background: var(--bg-light);
}

.db-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.db-panel {
    display: none;
}

.db-panel.active {
    display: block;
}

/* User Detail Tabs */
.user-detail-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.user-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.user-tab:hover {
    color: var(--text-primary);
}

.user-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.user-tab-content {
    display: none;
}

.user-tab-content.active {
    display: block;
}

/* Summary Cards */
.user-charts-summary,
.visits-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.summary-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-value.expense {
    color: var(--error);
}

.summary-value.income {
    color: var(--success);
}

/* User Charts Grid */
.user-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.user-chart-card {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 16px;
}

.user-chart-card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.user-chart-canvas {
    height: 180px;
}

/* Visits List */
.visits-list {
    max-height: 400px;
    overflow-y: auto;
}

.visit-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 8px;
}

.visit-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visit-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--primary);
}

.visit-info {
    flex: 1;
}

.visit-time {
    font-weight: 500;
    margin-bottom: 2px;
}

.visit-detail {
    font-size: 12px;
    color: var(--text-muted);
}

.visit-duration {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

/* User Meta */
.user-meta {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    margin-top: 4px;
}
