/* ================================================
   ARSA Face SDK Dashboard - Dark Theme Stylesheet
   ================================================ */

/* === CSS Variables === */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;

    --border-color: #30363d;
    --border-light: #484f58;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #a371f7;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition: all 0.2s ease;

    --sidebar-width: 240px;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: #79c0ff;
}

/* === Login Page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0a0f14 100%);
}

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

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

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

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

.login-logo-img {
    width: 80px;
    height: 80px;
    display: block;
    margin: 0 auto 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

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

.login-form input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.login-form input::placeholder {
    color: var(--text-muted);
}

.error-message {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 16px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 12px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #79c0ff;
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #ff6b63;
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === App Layout === */
.app-container {
    display: flex;
    min-height: 100vh;
}

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

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
}

.logo-icon-img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.nav-menu {
    list-style: none;
    padding: 16px;
    flex: 1;
}

.nav-item {
    margin-bottom: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 16px;
}

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

.nav-link.active {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

.nav-text {
    font-size: 16px;
}

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

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.logout-btn:hover {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.user-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.content-area {
    padding: 24px;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* === Tables === */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.table-wrapper {
    overflow-x: auto;
}

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

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

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

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

.data-table .loading-row td,
.data-table .empty-row td,
.data-table .error-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* === Badges === */
.method-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.method-get {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
}

.method-post {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-blue);
}

.method-put {
    background: rgba(210, 153, 34, 0.2);
    color: var(--accent-yellow);
}

.method-delete {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-red);
}

.method-patch {
    background: rgba(163, 113, 247, 0.2);
    color: var(--accent-purple);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

.status-success {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
}

.status-warning {
    background: rgba(210, 153, 34, 0.2);
    color: var(--accent-yellow);
}

.status-error {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-red);
}

.status-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Role Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.badge-primary {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-blue);
}

.badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-success {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-green);
}

.badge-danger {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-red);
}

.text-muted {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

.result-message {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.result-message.success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.result-message.error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

/* === Filters === */
.filters-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.filters-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    min-width: 150px;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-indicator {
    color: var(--text-secondary);
    font-size: 14px;
}

/* === Modals === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.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);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

/* === Settings Page === */
.settings-page .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.settings-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    font-family: monospace;
    color: var(--accent-blue);
}

.warning-text {
    color: var(--accent-yellow);
    font-size: 14px;
}

.key-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-top: 12px;
}

.key-display code {
    flex: 1;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    word-break: break-all;
}

.key-code {
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* === Log Details === */
.log-detail {
    font-size: 14px;
}

.detail-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row strong {
    min-width: 100px;
    color: var(--text-secondary);
}

.detail-section {
    margin-top: 16px;
}

.detail-section strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.code-block {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    max-height: 300px;
    white-space: pre-wrap;
    word-break: break-word;
}

.endpoint-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Sandbox Page === */
.sandbox-page .card {
    margin-bottom: 24px;
}

.sandbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.sandbox-grid.three-columns {
    grid-template-columns: repeat(3, 1fr);
}

.sandbox-section {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.sandbox-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.sandbox-form .form-group {
    margin-bottom: 12px;
}

.result-box {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

.result-box.success {
    border-color: var(--accent-green);
}

.result-box.error {
    border-color: var(--accent-red);
}

.result-box pre {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.result-box .placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

.result-box .loading {
    color: var(--accent-blue);
    text-align: center;
    padding: 20px 0;
}

.db-list {
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.db-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

/* === Webcam === */
.webcam-container {
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

.webcam-container video {
    width: 100%;
    display: block;
}

.webcam-controls {
    display: flex;
    gap: 12px;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.instructions-box {
    margin-top: 16px;
    padding: 16px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-md);
}

.instruction-text {
    margin-bottom: 12px;
    font-size: 14px;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* === Loading === */
.loading {
    color: var(--accent-blue);
    text-align: center;
}

/* === Responsive === */
@media (max-width: 1200px) {
    .sandbox-grid.three-columns {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .settings-page .settings-grid {
        grid-template-columns: 1fr;
    }

    .sandbox-grid,
    .sandbox-grid.three-columns {
        grid-template-columns: 1fr;
    }
}