/* WhatsApp Dashboard Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #25D366;
    --primary-dark: #128C7E;
    --secondary-color: #34B7F1;
    --bg-color: #F0F2F5;
    --sidebar-bg: #FFFFFF;
    --text-primary: #111B21;
    --text-secondary: #667781;
    --border-color: #E9EDEF;
    --success-color: #00A884;
    --danger-color: #E53E3E;
    --warning-color: #FFA500;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.sidebar-nav {
    padding: 10px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    position: relative;
    z-index: 1;
    gap: 12px;
    border-radius: 8px;
    margin: 4px 8px;
}

.nav-item:hover {
    background-color: var(--bg-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-item .icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 8px 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 16px);
    margin: 0 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--danger-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-logout-btn:hover {
    background: rgba(229, 62, 62, 0.08);
}

.sidebar-logout-btn .icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 28px;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 48px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 12px;
}

.stat-info h3 {
    font-size: 32px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #C53030;
}

.btn-secondary {
    background-color: var(--text-secondary);
    color: white;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--bg-color);
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

tbody tr:hover {
    background-color: var(--bg-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #D4EDDA;
    color: #155724;
}

.badge-danger {
    background-color: #F8D7DA;
    color: #721C24;
}

.badge-warning {
    background-color: #FFF3CD;
    color: #856404;
}

.badge-info {
    background-color: #D1ECF1;
    color: #0C5460;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Forms */
.form-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

/* Checkbox/radio di form-group: jangan width 100% (pecah layout flex label + teks) */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 3px;
}

/* Daftar izin API key — rapat, teks menempel checkbox */
.api-key-permissions-checklist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.form-group .api-key-permissions-checklist > label {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 2px 0;
    font-weight: 400;
    cursor: pointer;
}

.form-group .api-key-permissions-checklist > label strong {
    font-weight: 600;
}

.form-group .api-key-permissions-checklist .perm-text {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

.form-group .api-key-permissions-checklist .perm-desc {
    display: block;
    color: var(--text-secondary, #6c757d);
    font-size: 12px;
    font-weight: normal;
    line-height: 1.35;
    margin-top: 1px;
}

.form-group .api-key-permissions-hint {
    font-size: 12px;
    color: var(--text-secondary, #6c757d);
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }

    .sidebar-header p,
    .nav-item span:not(.icon) {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* QR Code Styles */
.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-header {
    margin-bottom: 20px;
}

.qr-header h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
}

.qr-header p {
    color: var(--text-secondary);
    margin: 0;
}

.qr-code-wrapper {
    margin: 20px 0;
    padding: 30px;
    background: #ffffff;
    border: 2px dashed #25D366;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 400px;
    min-height: 400px;
    position: relative;
}

.qr-code-image,
.qr-code-wrapper canvas {
    max-width: 400px;
    width: 400px;
    height: 400px;
    border: 4px solid #25D366;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(37, 211, 102, 0.2);
    background: white;
    padding: 10px;
}

.qr-loading {
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #25D366;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.qr-instructions {
    margin-top: 30px;
    text-align: left;
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.qr-instructions h4 {
    margin-top: 0;
    color: #1976D2;
}

.qr-instructions ol {
    margin: 15px 0;
    padding-left: 20px;
}

.qr-instructions li {
    margin: 10px 0;
}

.qr-note {
    margin-top: 15px;
    font-style: italic;
    color: #666;
    font-size: 14px;
}

.qr-status {
    margin: 10px 0;
    font-size: 14px;
}

.qr-status .badge {
    margin-left: 5px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* API Info Styles */
.info-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.api-info {
    margin: 20px 0;
}

.info-item {
    margin: 15px 0;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.info-item code {
    background: #e0e0e0;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    flex: 1;
    min-width: 200px;
}

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
}

.api-endpoints {
    margin: 20px 0;
}

.api-endpoints ul {
    list-style: none;
    padding: 0;
}

.api-endpoints li {
    padding: 8px;
    margin: 5px 0;
    background: #f9f9f9;
    border-left: 3px solid #25D366;
    border-radius: 4px;
}

.api-endpoints code {
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.api-keys-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.api-keys-list {
    margin: 15px 0;
}

.api-key-item {
    padding: 15px;
    margin: 10px 0;
    background: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.api-key-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.api-key-value {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.api-key-value code {
    flex: 1;
    background: #e0e0e0;
    padding: 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.page-header-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header-sub h3 {
    margin: 0;
}

/* Badge Warning & Info */
.badge-warning {
    background: #ff9800;
    color: white;
}

.badge-info {
    background: #2196F3;
    color: white;
}

.btn-info {
    background: #2196F3;
    color: white;
}

.btn-info:hover {
    background: #1976D2;
}

.alert {
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

.alert-info {
    background: #e3f2fd;
    border-left: 4px solid #2196F3;
    color: #1976D2;
}

.alert-info code {
    background: rgba(255,255,255,0.7);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.alert-success {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    color: #2e7d32;
}

.alert-success ol {
    margin: 10px 0 0 20px;
    padding: 0;
}

.alert-success li {
    margin: 8px 0;
    line-height: 1.6;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.info-banner {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2196F3;
}

.info-banner strong {
    color: #1976D2;
    display: block;
    margin-bottom: 5px;
}

.info-banner p {
    margin: 5px 0 0 0;
    font-size: 14px;
    color: #424242;
    line-height: 1.5;
}

.text-muted {
    color: #666;
    font-size: 12px;
    display: block;
    margin-top: 5px;
}

/* API key table cell */
.api-key-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.api-key-cell code.api-key-display {
    display: block;
    word-break: break-all;
    font-size: 12px;
    padding: 8px 10px;
    background: #f5f7f8;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.api-key-cell-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* API documentation */
.docs-content {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 960px;
    overflow-x: auto;
}

.docs-content h1 {
    font-size: 28px;
    margin-bottom: 16px;
    color: var(--primary-dark);
}

.docs-content h2 {
    font-size: 22px;
    margin: 28px 0 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.docs-content h3 {
    font-size: 18px;
    margin: 20px 0 10px;
}

.docs-content p,
.docs-content ul {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.docs-content ul {
    padding-left: 24px;
}

.docs-content li {
    margin-bottom: 6px;
}

.docs-content code {
    background: #eef2f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.docs-content pre {
    background: #1e1e1e;
    color: #f3f3f3;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0 16px;
}

.docs-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 13px;
}

.docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 16px;
    font-size: 14px;
}

.docs-content th,
.docs-content td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
}

.docs-content th {
    background: #f5f7f8;
}

.docs-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

