:root {
    --bg-dark: #0a0c10;
    --bg-card: #161b22;
    --bg-input: #0d1117;
    --accent: #ff9f00;
    --accent-hover: #ffb733;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --border: #30363d;
    --danger: #f85149;
    --success: #3fb950;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

#mainApp {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    margin-bottom: 3rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 159, 0, 0.15);
}

.filter-box select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.filter-box select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Certificate Cards */
.cert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.cert-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
    animation: fadeIn 0.4s ease-out;
}

.cert-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.cert-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: rgba(63, 185, 80, 0.1);
    color: var(--success);
}

.status-expired {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
}

.cert-info h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.cert-info .company {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.cert-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.cert-actions {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-secondary {
    background: #21262d;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #30363d;
}

.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    animation: slideUp 0.3s ease-out;
}

.modal-lg { max-width: 900px; height: 90vh; }
.modal-sm { max-width: 400px; }

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    appearance: none; /* For custom select arrow if needed */
}

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

.file-upload-wrapper {
    margin-top: 0.5rem;
}

.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.file-drop-zone:hover, .file-drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(255, 159, 0, 0.05);
}

.file-name-display {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--accent);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* PDF Viewer */
.pdf-container {
    width: 100%;
    height: calc(100% - 60px);
}

#pdfFrame {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem 1rem;
    background: var(--bg-card);
    border-radius: 20px;
    border: 2px dashed var(--border);
}

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

.empty-state p {
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Profile Modal */
.profile-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.profile-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.profile-value {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Login View */
.login-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(255, 159, 0, 0.1), transparent),
                radial-gradient(circle at bottom left, rgba(255, 159, 0, 0.05), transparent),
                var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand .logo {
    justify-content: center;
}

.login-card {
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    font-size: 1.1rem;
    opacity: 0.6;
}

.input-with-icon input {
    width: 100%;
    padding-left: 2.8rem;
}

.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.25rem 0;
    font-size: 0.875rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
}

.checkbox-container:hover .checkmark {
    border-color: var(--accent);
}

.checkbox-container input:checked + .checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-container input:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    color: #000;
    font-size: 12px;
    font-weight: 900;
    left: 3px;
    top: -1px;
}

.forgot-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.forgot-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    padding: 0 1rem;
}

.demo-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.demo-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 12px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-align: center;
    transition: var(--transition);
}

.demo-badge:hover {
    background: rgba(255, 159, 0, 0.05);
    border-color: rgba(255, 159, 0, 0.2);
    color: var(--accent);
}

.error-text {
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    height: 1.2rem;
    text-align: center;
}

.btn-block {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
}

.user-badge {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 159, 0, 0.1);
    border: 1px solid rgba(255, 159, 0, 0.2);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-left: 1rem;
}

/* User Management */
.user-mgmt-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.user-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.user-form-grid input {
    width: 100%;
}

.user-list-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

.user-list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.user-info-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.user-display-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.user-username-handle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-role-tag {
    padding: 0.2rem 0.75rem;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: rgba(255, 159, 0, 0.1);
    color: var(--accent);
    border: 1px solid rgba(255, 159, 0, 0.2);
}

.role-executive {
    background: rgba(63, 185, 80, 0.1);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.system-tag {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.7;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
}

@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .cert-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 140px;
        justify-content: center;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .search-box {
        max-width: none;
    }

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

    .cert-card {
        padding: 1.25rem;
    }

    .cert-actions {
        flex-direction: column;
    }

    .cert-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .modal {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-grid, .profile-grid {
        grid-template-columns: 1fr;
    }

    .user-form-grid {
        grid-template-columns: 1fr;
    }

    .toast-container {
        top: auto;
        bottom: 1.5rem;
        right: 1.5rem;
        left: 1.5rem;
    }

    .toast {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 2rem 1.25rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.875rem;
    }
}

/* Footer Styles */
.app-footer {
    padding: 3rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
    margin: 4rem auto 0;
    max-width: 1200px;
}

.app-footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    opacity: 0.7;
}
