/* Existing shared controls, retained for compatibility with the PHP views. */
:root {
    --primary: #155dfc;
    --primary-hover: #1a6aff;
    --primary-light: #239cff;
    --primary-subtle: rgba(21, 93, 252, 0.12);
    --bg: #161b26;
    --card-bg: #1a2030;
    --text: #f3f5f8;
    --text-secondary: #8b95a5;
    --text-tertiary: #555d6b;
    --border: #252b37;
    --success: #4ade80;
    --success-bg: rgba(52, 168, 83, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 188, 4, 0.12);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --sidebar-width: 260px;
    --header-height: 60px;
    --header-bg: #0f1219;
    --sidebar-bg: #0f1219;
    --nav-text: #8b95a5;
    --nav-text-secondary: #555d6b;
}

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

body {
    font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-light);
}

a:visited {
    color: var(--primary-light);
}

a:hover {
    color: #5eb8ff;
}

h1, h2, h3, h4, h5, h6, .card-title, .stat-value {
    font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-weight: 600;
}

/* Top header bar */
.header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.burger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    color: var(--nav-text);
}

.burger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.burger-btn svg {
    display: block;
    width: 24px;
    height: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    height: 36px;
}

.logo svg {
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 17px;
    color: #fff;
    letter-spacing: -0.3px;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    color: var(--nav-text-secondary);
    font-size: 0.9rem;
}

.logout-link {
    color: var(--nav-text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.logout-link:hover {
    color: #fff;
}

/* Sidebar navigation */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 900;
    transition: transform 0.3s ease;
}

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

.nav-section {
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--nav-text-secondary);
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--nav-text);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-link:visited {
    color: var(--nav-text);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.nav-link.active {
    background: var(--card-bg);
    color: #fff;
    border-left: 3px solid var(--primary);
    border-radius: 0;
    margin-left: 0;
}

.nav-link.active svg {
    color: var(--primary-light);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: linear-gradient(90deg, var(--border) 0%, transparent 80%);
    margin: 2px 0 2px 1rem;
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 800;
}

/* Main content area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Card styles */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Button styles */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.2;
    box-sizing: border-box;
}

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

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

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

.btn-secondary:hover {
    border-color: #2a3040;
    color: var(--text);
}

/* Form styles */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 93, 252, 0.15);
}

/* Alert styles */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

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

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 168, 83, 0.2);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 10px;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-suspended { background: var(--error-bg); color: var(--error); }
.status-terminated { background: rgba(107, 114, 128, 0.12); color: #6b7280; }
.status-cancelled { background: rgba(107, 114, 128, 0.12); color: #6b7280; }

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

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

.service-card:hover {
    border-color: #2a3040;
}

.service-card a {
    text-decoration: none;
    color: inherit;
}

.service-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.service-domain {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.service-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.service-price {
    font-weight: 600;
    color: var(--text);
}

.service-cycle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item {
    padding: 1rem;
    background: #0f1219;
    border-radius: 8px;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

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

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

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

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

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

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

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

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

.stat-card.primary .stat-value,
.stat-card.primary .stat-label {
    color: white;
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    border-color: #333b4a;
    color: var(--text);
    background: #1e2538;
}

.quick-action-btn svg {
    width: 18px;
    height: 18px;
}

/* Services list (dashboard) */
.services-list {
    display: flex;
    flex-direction: column;
}

.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

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

.service-info {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    min-width: 0;
    flex: 1;
}

.service-info:hover .service-name {
    color: var(--primary);
}

.service-row .service-name {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-row .service-domain {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-action {
    flex-shrink: 0;
}

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

@media (max-width: 480px) {
    .service-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .service-action {
        align-self: flex-start;
    }
}

/* Activity list */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.activity-content {
    flex: 1;
}

.activity-text {
    color: var(--text);
    margin-bottom: 0.25rem;
}

.activity-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .burger-btn {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-wrapper {
        margin-left: 0;
    }

    .container {
        padding: 1rem;
    }

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

    .user-info {
        display: none;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
