/* =====================================================
   NatoChat - WhatsApp Gateway API Dashboard
   Premium Dark Mode Design
   ===================================================== */

:root {
    /* Colors */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-card: #1e1e1e;
    --bg-hover: #2a2a2a;

    --accent-primary: #00d26a;
    --accent-secondary: #00b35a;
    --accent-gradient: linear-gradient(135deg, #00d26a 0%, #00a65a 100%);

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;

    --border-color: #333333;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Status colors */
    --status-connected: #00d26a;
    --status-pending: #ffa500;
    --status-disconnected: #ff4757;
    --status-sent: #00d26a;
    --status-failed: #ff4757;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

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

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

/* =====================================================
   Lucide Icons Styling
   ===================================================== */

.logo-icon i,
.logo-icon svg {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    stroke-width: 1.5;
}

.sidebar-header .logo-icon i,
.sidebar-header .logo-icon svg {
    width: 28px;
    height: 28px;
}

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

.stat-icon i,
.stat-icon svg {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
    stroke-width: 1.5;
}

.btn i,
.btn svg {
    width: 18px;
    height: 18px;
}

.icon-lg {
    width: 48px;
    height: 48px;
}

/* =====================================================
   Authentication Section
   ===================================================== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(0, 210, 106, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(0, 210, 106, 0.05) 0%, transparent 50%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

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

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Tab Buttons */
.tab-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--accent-gradient);
    color: var(--bg-primary);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 210, 106, 0.15);
}

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

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--bg-primary);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 210, 106, 0.3);
}

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

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

.btn-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

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

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: 16px;
}

.message.success {
    background: rgba(0, 210, 106, 0.15);
    border: 1px solid rgba(0, 210, 106, 0.3);
    color: var(--accent-primary);
}

.message.error {
    background: rgba(255, 71, 87, 0.15);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: var(--status-failed);
}

.hidden {
    display: none !important;
}

/* =====================================================
   Dashboard Layout
   ===================================================== */

.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo-icon {
    font-size: 28px;
    margin: 0;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

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

.nav-item.active {
    background: rgba(0, 210, 106, 0.15);
    color: var(--accent-primary);
}

.nav-icon {
    font-size: 18px;
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    background: var(--bg-primary);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.main-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

#content-area {
    padding: 32px;
}

/* =====================================================
   Stats Grid (Overview)
   ===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 32px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    display: block;
}

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

.api-key-display {
    font-size: 14px;
    font-family: monospace;
    word-break: break-all;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.card h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.quick-start-list {
    padding-left: 20px;
}

.quick-start-list li {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.quick-start-list strong {
    color: var(--accent-primary);
}

/* =====================================================
   Devices Grid
   ===================================================== */

.page-actions {
    margin-bottom: 24px;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all 0.2s ease;
}

.device-card:hover {
    border-color: var(--accent-primary);
}

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

.device-name {
    font-size: 18px;
    font-weight: 600;
}

.device-phone {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-connected {
    background: rgba(0, 210, 106, 0.15);
    color: var(--status-connected);
}

.status-disconnected {
    background: rgba(255, 71, 87, 0.15);
    color: var(--status-disconnected);
}

.status-qr_pending,
.status-connecting {
    background: rgba(255, 165, 0, 0.15);
    color: var(--status-pending);
}

.device-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* =====================================================
   Modal
   ===================================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

/* =====================================================
   Data Table
   ===================================================== */

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

.data-table th,
.data-table td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.data-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px !important;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.pagination button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

/* =====================================================
   API Docs
   ===================================================== */

.endpoint {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
}

.endpoint .method {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 8px;
}

.method.get {
    background: #3498db;
    color: white;
}

.method.post {
    background: #2ecc71;
    color: white;
}

.method.delete {
    background: #e74c3c;
    color: white;
}

.endpoint code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 14px;
    color: var(--accent-primary);
}

.endpoint p {
    margin: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.endpoint pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    overflow-x: auto;
}

.endpoint pre code {
    color: var(--text-primary);
    font-size: 13px;
}

#page-api-docs code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', Consolas, monospace;
}

#page-api-docs h4 {
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =====================================================
   Toast Notification
   ===================================================== */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 24px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-color: var(--accent-primary);
}

.toast.error {
    border-color: var(--status-failed);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

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

    .dashboard {
        flex-direction: column;
    }

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

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

    .data-table {
        display: block;
        overflow-x: auto;
    }
}