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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f0f;
    color: #e8e8e8;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===== Login View ===== */
.login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    padding: 48px 40px;
    width: 380px;
    text-align: center;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: #ff4444;
    margin-bottom: 6px;
}

.login-subtitle {
    color: #888;
    font-size: 14px;
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #e8e8e8;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-form input:focus {
    border-color: #ff4444;
}

.error-msg {
    color: #ff6b6b;
    font-size: 13px;
    text-align: left;
    padding: 8px 12px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 6px;
}

/* ===== Buttons ===== */
.primary-btn {
    padding: 12px 24px;
    background: #ff4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #e03030;
}

.primary-btn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

.copy-btn,
.filter-btn {
    padding: 6px 14px;
    background: transparent;
    color: #e8e8e8;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover,
.filter-btn:hover {
    border-color: #ff4444;
    color: #ff4444;
}

.lang-toggle-btn {
    padding: 4px 10px;
    background: #222;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 32px;
    text-align: center;
}

.lang-toggle-btn:hover {
    border-color: #ff4444;
    color: #ff4444;
    background: #1a1a1a;
}

.logout-btn {
    padding: 6px 16px;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: #ff4444;
    color: #ff4444;
}

/* ===== Dashboard Header ===== */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid #1a1a1a;
}

.dash-title {
    font-size: 20px;
    font-weight: 700;
    color: #ff4444;
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-ok {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.status-error {
    background: #ff4444;
}

.status-unknown {
    background: #666;
}

.admin-user-label {
    color: #888;
    font-size: 13px;
}

/* ===== Stats Bar ===== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 20px 28px;
}

.stat-card {
    background: #1a1a1a;
    border-radius: 10px;
    padding: 18px 20px;
    border-left: 3px solid #333;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card.stat-active {
    border-left-color: #22c55e;
}

.stat-card.stat-unactivated {
    border-left-color: #fbbf24;
}

.stat-card.stat-expired {
    border-left-color: #f87171;
}

.stat-card.stat-revoked {
    border-left-color: #666;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.stat-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Dashboard Layout ===== */
.dash-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    padding: 0 28px 28px;
}

.section-card {
    background: #1a1a1a;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    color: #e8e8e8;
}

/* ===== Key Generation ===== */
.gen-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.gen-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.gen-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 100px;
}

.gen-field-wide {
    flex: 1;
}

.gen-field label {
    font-size: 12px;
    color: #888;
}

.gen-field input {
    padding: 9px 12px;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e8e8e8;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.gen-field input:focus {
    border-color: #ff4444;
}

.gen-result {
    margin-top: 16px;
    border-top: 1px solid #2a2a2a;
    padding-top: 16px;
}

.gen-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: #888;
}

.gen-keys-list {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 14px 16px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #4ade80;
    line-height: 1.8;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* ===== Key Management ===== */
.keys-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.status-tabs {
    display: flex;
    gap: 4px;
}

.tab-btn {
    padding: 6px 14px;
    background: transparent;
    color: #888;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #e8e8e8;
    border-color: #555;
}

.tab-btn.active {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
}

.key-search-input {
    padding: 7px 12px;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e8e8e8;
    font-size: 13px;
    outline: none;
    width: 200px;
    transition: border-color 0.2s;
}

.key-search-input:focus {
    border-color: #ff4444;
}

/* ===== Table ===== */
.table-wrapper {
    overflow-x: auto;
}

.keys-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.keys-table th {
    text-align: left;
    padding: 10px 12px;
    background: #161616;
    color: #888;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #2a2a2a;
    white-space: nowrap;
}

.keys-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #1e1e1e;
    vertical-align: middle;
}

.keys-table tbody tr:hover {
    background: #222;
}

.key-cell {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #ccc;
    white-space: nowrap;
}

.machine-cell {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #888;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-cell {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.notes-cell {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #666;
    font-size: 12px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-unactivated {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.badge-expired {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.badge-revoked {
    background: rgba(102, 102, 102, 0.2);
    color: #999;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.action-btn {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid #333;
    background: transparent;
    color: #ccc;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: #555;
    background: #2a2a2a;
}

.action-btn.btn-danger {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

.action-btn.btn-danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #f87171;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.page-btn {
    padding: 6px 12px;
    background: transparent;
    color: #888;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: #555;
    color: #e8e8e8;
}

.page-btn.active {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
}

/* ===== Activation Log ===== */
.dash-sidebar .section-card {
    margin-bottom: 0;
}

.log-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.log-filter input {
    flex: 1;
    padding: 7px 10px;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e8e8e8;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.log-filter input:focus {
    border-color: #ff4444;
}

.log-list {
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-entry {
    padding: 10px 12px;
    background: #161616;
    border-radius: 8px;
    border-left: 3px solid #333;
    font-size: 12px;
}

.log-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.log-action {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.log-action.act-activate { color: #4ade80; }
.log-action.act-deactivate { color: #fbbf24; }
.log-action.act-generate { color: #60a5fa; }
.log-action.act-revoke { color: #f87171; }
.log-action.act-reset { color: #c084fc; }
.log-action.act-extend { color: #34d399; }

.log-time {
    color: #555;
    font-size: 11px;
    font-family: 'Courier New', monospace;
}

.log-key {
    font-family: 'Courier New', monospace;
    color: #888;
    font-size: 11px;
}

.log-details {
    color: #666;
    font-size: 11px;
    margin-top: 2px;
}

.empty-text {
    color: #555;
    text-align: center;
    padding: 20px 0;
    font-size: 13px;
}

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

.modal-box {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    width: 420px;
    max-width: 90vw;
    animation: slideIn 0.2s ease-out;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px 24px;
    font-size: 14px;
    color: #ccc;
    line-height: 1.6;
}

.modal-body input {
    width: 100%;
    padding: 10px 12px;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e8e8e8;
    font-size: 14px;
    outline: none;
    margin-top: 10px;
}

.modal-body input:focus {
    border-color: #ff4444;
}

.modal-body .modal-key {
    font-family: 'Courier New', monospace;
    color: #fbbf24;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #2a2a2a;
}

.modal-cancel-btn {
    padding: 8px 20px;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.modal-cancel-btn:hover {
    color: #e8e8e8;
    border-color: #555;
}

.modal-confirm-btn {
    padding: 8px 20px;
    background: #ff4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.modal-confirm-btn:hover {
    background: #e03030;
}

.modal-confirm-btn.btn-danger {
    background: #dc2626;
}

.modal-confirm-btn.btn-danger:hover {
    background: #b91c1c;
}

/* ===== Animations ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Devices Count ===== */
.devices-count {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 13px;
    color: #4ade80;
    font-weight: 600;
}

.devices-count.dim {
    color: #555;
    font-weight: 400;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .stats-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    .dash-layout {
        grid-template-columns: 1fr;
    }

    .gen-row {
        flex-wrap: wrap;
    }

    .keys-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .key-search-input {
        width: 100%;
    }
}
