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

:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --border-color: #bdc3c7;
    --text-color: #333;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ecf0f1;
    color: var(--text-color);
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin-bottom: 15px;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95em;
}

.role-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.role-badge.role-admin {
    background: #e74c3c;
    border-color: #c0392b;
}

.role-badge.role-user {
    background: #3498db;
    border-color: #2980b9;
}

.btn-logout {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-weight: 500;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

.header-content h1 {
    font-size: 2em;
    margin-bottom: 0;
}

.header-content p {
    font-size: 1em;
    opacity: 0.9;
    margin: 0;
}

/* Sidebar */
.sidebar {
    display: none;
}

.nav {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-left: auto;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    color: white;
    white-space: nowrap;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
    font-weight: bold;
}

.nav-btn .icon {
    font-size: 1.2em;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px;
    background: #ecf0f1;
    overflow-y: auto;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.8em;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2.5em;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-icon.total {
    background: #e8f4f8;
}

.stat-icon.active {
    background: #e8f5e9;
}

.stat-icon.inactive {
    background: #fff3e0;
}

.stat-icon.expired {
    background: #ffebee;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--secondary-color);
}

/* Recent Keys Section */
.recent-keys {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.recent-keys h3 {
    margin-bottom: 20px;
    color: var(--secondary-color);
}

/* Table */
.table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--light-bg);
}

.table tbody tr:hover {
    background: var(--light-bg);
}

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

.text-center {
    text-align: center;
    color: #999;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-expired {
    background: #fff3cd;
    color: #856404;
}

/* Days Remaining Badge */
.days-remaining {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
}

.days-ok {
    background: #d4edda;
    color: #155724;
}

.days-warning {
    background: #fff3cd;
    color: #856404;
}

.days-danger {
    background: #f8d7da;
    color: #721c24;
}

.days-expired {
    background: #f5c6cb;
    color: #721c24;
    font-weight: bold;
}

/* View Header */
.view-header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.view-header h2 {
    margin-bottom: 0;
}

.search-box {
    display: flex;
    gap: 10px;
}

.search-box input {
    padding: 10px 15px;
    border: 2px solid var(--light-bg);
    border-radius: 8px;
    font-size: 1em;
    width: 300px;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Forms */
.form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 0 auto;
}

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

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

.required {
    color: var(--danger-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light-bg);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #f9f9f9;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

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

.btn-secondary:hover {
    background: #a9adb5;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #229954;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

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

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    color: var(--secondary-color);
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

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

.modal-body {
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    display: none;
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

.notification.show {
    display: block;
}

.notification.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.notification.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.notification.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .nav-btn {
        flex: 1;
        white-space: nowrap;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .nav {
        margin-left: 0;
        width: 100%;
        overflow-x: auto;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-box {
        width: 100%;
    }

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

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

    .table {
        font-size: 0.9em;
    }

    .table th,
    .table td {
        padding: 8px;
    }

    .modal-content {
        width: 95%;
    }
}

/* Loading Animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ============ USERS MANAGEMENT ============ */
.management-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.management-section h3 {
    margin-top: 0;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.management-section h4 {
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.assign-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: flex-end;
}

.assign-section label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9em;
}

.assign-section select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
}

.assign-section button {
    width: 100%;
}

.btn-header {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}
