/**
 * 5dkey Credential Server 2.0 - Dark Theme
 * (c) Sitepics.app Pty Ltd (5dkey)
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #0a1628;
    color: #c9d6e3;
    min-height: 100vh;
    line-height: 1.6;
}

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

/* Headers */
h1, h2, h3 {
    color: #5fb4f5;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.subtitle {
    color: #8ba3c4;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.version {
    color: #6b8bb5;
    font-size: 0.85rem;
}

hr {
    border: none;
    border-top: 1px solid #2d5a8a;
    margin: 1.5rem 0;
}

/* Header row */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    background-color: #0d1f3c;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1.5rem;
    gap: 2px;
}

.tab {
    flex: 1;
    min-width: 120px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: #8ba3c4;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-align: center;
}

.tab:hover {
    color: #5fb4f5;
    background-color: rgba(26, 58, 92, 0.5);
}

.tab.active {
    background-color: #1a3a5c;
    color: #5fb4f5;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form elements */
label {
    display: block;
    margin-bottom: 0.5rem;
    color: #c9d6e3;
    font-size: 0.95rem;
    font-weight: 500;
}

.label-hint {
    color: #6b8bb5;
    font-weight: normal;
    font-size: 0.85rem;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    max-width: 400px;
    padding: 10px 12px;
    background-color: #1a3a5c;
    color: #ffffff;
    border: 1px solid #2d5a8a;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #5fb4f5;
}

input::placeholder {
    color: #6b8bb5;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Checkbox and radio */
.checkbox-group,
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #5fb4f5;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    background-color: #1e5a9e;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background-color: #2d7ad6;
}

.btn:disabled {
    background-color: #4a5568;
    cursor: not-allowed;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-success {
    background-color: #2d8a5a;
}

.btn-success:hover {
    background-color: #3ba86e;
}

.btn-warning {
    background-color: #c9a227;
}

.btn-warning:hover {
    background-color: #d4b13a;
}

.btn-danger {
    background-color: #9e3a3a;
}

.btn-danger:hover {
    background-color: #c04545;
}

.btn-secondary {
    background-color: #4a5568;
}

.btn-secondary:hover {
    background-color: #5a6578;
}

/* Code blocks */
.code-block {
    background-color: #1a3a5c;
    color: #7fdbca;
    padding: 12px 16px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin-bottom: 0.75rem;
    word-break: break-all;
    white-space: pre-wrap;
}

.code-block.large {
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Copy button row */
.copy-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Cards */
.card {
    background-color: #0d1f3c;
    border: 1px solid #2d5a8a;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    margin: 0;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: #0d1f3c;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #2d5a8a;
}

th {
    background-color: #1a3a5c;
    color: #5fb4f5;
    font-weight: 600;
    font-size: 0.9rem;
}

tr:hover {
    background-color: rgba(26, 58, 92, 0.5);
}

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

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #1a4a3c;
    border: 1px solid #2d8a5a;
    color: #7fdbca;
}

.alert-info {
    background-color: #1a3a5c;
    border: 1px solid #2d5a8a;
    color: #c9d6e3;
}

.alert-warning {
    background-color: #4a3a1a;
    border: 1px solid #8a6a2d;
    color: #f5d67f;
}

.alert-error {
    background-color: #4a1a1a;
    border: 1px solid #8a2d2d;
    color: #f57f7f;
}

/* Form sections */
.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2d5a8a;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row > * {
    flex: 1;
    min-width: 200px;
}

/* TODDOW Schedule Grid */
.toddow-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.toddow-day {
    font-weight: 500;
    padding: 8px;
    background-color: #1a3a5c;
    border-radius: 4px;
    text-align: center;
}

.toddow-input {
    max-width: none;
    margin-bottom: 0;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #2d8a5a;
    color: white;
}

.badge-warning {
    background-color: #c9a227;
    color: black;
}

.badge-error {
    background-color: #9e3a3a;
    color: white;
}

.badge-info {
    background-color: #1e5a9e;
    color: white;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #2d5a8a;
    border-top-color: #5fb4f5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Flash messages */
.flash-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6b8bb5;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Utility classes */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: #6b8bb5; }
.text-success { color: #7fdbca; }
.text-warning { color: #f5d67f; }
.text-error { color: #f57f7f; }
.text-small { font-size: 0.85rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: 'Consolas', 'Monaco', monospace; }

/* Generated eKey display */
.ekey-display {
    background-color: #0d1f3c;
    border: 2px solid #2d8a5a;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.ekey-display h3 {
    color: #7fdbca;
    margin-bottom: 1rem;
}

.ekey-string {
    background-color: #1a3a5c;
    color: #7fdbca;
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    margin-bottom: 1rem;
    max-height: 150px;
    overflow-y: auto;
}

/* Firmware Provisioning Panel */
.firmware-panel td {
    background-color: #0d2137 !important;
    padding: 0 !important;
}

.firmware-credentials {
    padding: 1.5rem;
    border: 2px solid #2a5a8a;
    border-radius: 8px;
    margin: 0.5rem;
}

.firmware-credentials h4 {
    color: #5fb4f5;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2a5a8a;
}

.firmware-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.firmware-row label {
    min-width: 160px;
    color: #8ba3c4;
    font-weight: 500;
}

.firmware-row code {
    flex: 1;
    background-color: #1a3a5c;
    color: #7fdbca;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    min-width: 200px;
}

.firmware-row .btn {
    flex-shrink: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #0d2137;
    border: 1px solid #2a5a8a;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2a5a8a;
}

.modal-header h3 {
    margin: 0;
    color: #5fb4f5;
}

#edit-modal-body {
    padding: 1.5rem;
}

#edit-modal-body .form-row {
    margin-bottom: 1rem;
}

#edit-modal-body label {
    display: block;
    margin-bottom: 0.25rem;
    color: #8ba3c4;
}

#edit-modal-body input,
#edit-modal-body select {
    width: 100%;
}

.disabled-input {
    background-color: #1a3a5c !important;
    color: #7fdbca !important;
    cursor: not-allowed;
}

/* Tiny button for inline copy */
.btn-tiny {
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Build Status Bar */
.build-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.build-status.build-active {
    background-color: rgba(45, 138, 90, 0.15);
    border: 1px solid #2d8a5a;
}

.build-status.build-none {
    background-color: rgba(201, 162, 39, 0.1);
    border: 1px solid #8a6a2d;
}

.build-status .build-icon {
    font-size: 1.2rem;
}

.build-status .build-label {
    color: #8ba3c4;
    font-weight: 500;
}

.build-status .build-code {
    background-color: #1a3a5c;
    color: #7fdbca;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: bold;
}

.build-status .build-name {
    color: #c9d6e3;
}

.build-status .build-hint {
    color: #6b8bb5;
    font-style: italic;
}

/* Current Build Highlight */
.current-build-row {
    background-color: rgba(45, 138, 90, 0.2) !important;
    border-left: 3px solid #2d8a5a;
}

.current-build-row td:first-child {
    border-left: 3px solid #2d8a5a;
}

.current-build-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Firmware provisioning row labels */
.fw-provision-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.fw-provision-row .fw-label {
    min-width: 160px;
    color: #8ba3c4;
    font-weight: 500;
}

.fw-provision-row .fw-value {
    flex: 1;
    min-width: 150px;
    background-color: #1a3a5c;
    color: #7fdbca;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    word-break: break-all;
}

.fw-provision-row .fw-file {
    color: #6b8bb5;
    font-size: 0.8rem;
    font-style: italic;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 2px;
    background-color: #0d1f3c;
    border-radius: 6px;
    padding: 3px;
    margin-bottom: 1rem;
}

.modal-tab {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #8ba3c4;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-align: center;
}

.modal-tab:hover {
    color: #5fb4f5;
    background-color: rgba(26, 58, 92, 0.5);
}

.modal-tab.active {
    background-color: #1a3a5c;
    color: #5fb4f5;
}

.modal-tab-content {
    min-height: 150px;
}

/* Session Cards */
.session-card {
    background-color: #1a3a5c;
    border: 1px solid #2d5a8a;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.session-details {
    margin-bottom: 0.5rem;
}

.session-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Empty state small (for modals) */
.empty-state-small {
    text-align: center;
    padding: 1.5rem;
    color: #6b8bb5;
}

/* Compact table for modals */
.table-compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table-compact th,
.table-compact td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #2d5a8a;
}

.table-compact th {
    background-color: #1a3a5c;
    color: #5fb4f5;
    font-weight: 600;
}

/* Badge danger */
.badge-danger {
    background-color: #9e3a3a;
    color: white;
}

/* Larger modal for user edit */
#edit-modal .modal-content {
    max-width: 600px;
}

/* Margin left helper */
.ml-1 { margin-left: 0.5rem; }

/* User menu in header */
.user-menu {
    position: relative;
    margin-left: 1rem;
}

.user-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #1a3a5c;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-menu-icon:hover {
    background-color: #2a5a8c;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background-color: #0d2137;
    border: 1px solid #2d5a8a;
    border-radius: 8px;
    padding: 1rem;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-header {
    font-size: 0.75rem;
    color: #6b8bb5;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.user-menu-email {
    font-weight: 600;
    color: #5fb4f5;
    margin-bottom: 0.25rem;
}

.user-menu-name {
    font-size: 0.85rem;
    color: #8ba3c4;
}

.user-menu-dropdown hr {
    border: none;
    border-top: 1px solid #2d5a8a;
    margin: 0.75rem 0;
}

.user-menu-logout {
    display: block;
    color: #f57f7f;
    text-decoration: none;
    font-size: 0.9rem;
}

.user-menu-logout:hover {
    color: #ff9999;
}
