/* ==================== CSS Variables ==================== */
:root {
    --primary: #00D9B5;
    --primary-dark: #00B89C;
    --primary-light: #00F5CC;
    --primary-glow: rgba(0, 217, 181, 0.3);
    --bg-dark: #0A0F1C;
    --bg-darker: #060A14;
    --bg-card: #111827;
    --bg-card-hover: #1F2937;
    --bg-input: #1F2937;
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    --border-color: #374151;
    --border-light: #4B5563;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

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

/* ==================== Sidebar ==================== */
.sidebar {
    width: 250px;
    background: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 217, 181, 0.1);
    color: var(--primary);
}

.nav-item.logout {
    color: var(--error);
}

.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

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

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-area {
    padding: 32px;
    flex: 1;
}

/* ==================== Admin Header ==================== */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-darker);
}

.admin-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-header .header-right {
    display: flex;
    align-items: center;
}

.admin-header .page-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-header .admin-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: none;
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

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

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.count-badge {
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 100px;
    font-weight: 600;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

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

.stats-sm {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon.users { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.stat-icon.agents { background: rgba(0, 217, 181, 0.15); color: var(--primary); }
.stat-icon.phones { background: rgba(139, 92, 246, 0.15); color: #8B5CF6; }
.stat-icon.kb { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.minutes { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.stat-icon.paid { background: rgba(0, 217, 181, 0.15); color: var(--primary); }
.stat-icon.free { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

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

/* ==================== Section Card ==================== */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

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

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.section-header h2 i {
    color: var(--primary);
}

/* ==================== Table ==================== */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

tbody td {
    padding: 12px 14px;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    color: var(--text-secondary);
}

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

tbody tr:last-child td {
    border-bottom: none;
}

.user-name {
    color: var(--text-primary);
    font-weight: 500;
}

.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==================== Badge ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-muted { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

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

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

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 217, 181, 0.05);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

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

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

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

.input-wrapper i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.input-wrapper input,
input[type="number"],
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary);
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form input {
    padding-left: 12px;
    flex: 1;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-form .input-wrapper {
    width: 280px;
}

/* ==================== Detail Grid ==================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* ==================== Info List ==================== */
.info-list {
    display: flex;
    flex-direction: column;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
}

.info-row:last-child {
    border-bottom: none;
}

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

.info-value {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

/* ==================== Minutes Form ==================== */
.minutes-form {
    padding: 4px 0;
}

/* ==================== Integrations ==================== */
.integrations-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.integration-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.integration-row span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==================== Alerts ==================== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

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

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* ==================== Login Page ==================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-darker);
}

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

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
}

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

.login-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 16px;
    display: block;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ==================== 404 / 500 ==================== */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--primary);
}

.error-page p {
    color: var(--text-secondary);
    margin: 16px 0;
}

/* ==================== Select / Filter ==================== */
.filter-select {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus {
    border-color: var(--primary);
}

.filter-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ==================== Chart Containers ==================== */
.section-card canvas {
    max-height: 300px;
}

/* ==================== Loading Spinner ==================== */
.fa-spinner {
    color: var(--primary);
    font-size: 1.5rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h2 span,
    .sidebar-nav .nav-item span,
    .sidebar-footer .admin-info span,
    .sidebar-footer .nav-item span {
        display: none;
    }

    .sidebar-header h2 {
        justify-content: center;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 60px;
    }

    .content-area {
        padding: 20px;
    }

    .admin-header {
        padding: 12px 20px;
    }

    .sidebar-toggle {
        display: block;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-form {
        width: 100%;
    }

    .search-form .input-wrapper {
        width: 100%;
        flex: 1;
    }
}
