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

:root {
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --primary: #6b7db3;
    --primary-hover: #5a6ca2;
    --accent: #7ec8a0;
    --accent-hover: #6bb78f;
    --text: #333340;
    --text-muted: #6b7280;
    --border: #d1d9e6;
    --border-light: #e8edf3;
    --nav-bg: #4a5a8a;
    --nav-text: #e8edf3;
    --status-red: #e8a0a0;
    --status-red-bg: #fdf0f0;
    --status-yellow: #e0c070;
    --status-yellow-bg: #fdf8ed;
    --status-green: #7ec8a0;
    --status-green-bg: #f0faf4;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

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

.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 360px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--nav-bg);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group select,
.form-group textarea,
.toolbar input,
.toolbar select,
.inline-form input,
.inline-form select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
.toolbar input:focus, .toolbar select:focus,
.inline-form input:focus, .inline-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(107, 125, 179, 0.2);
}

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

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn-outline {
    background: transparent;
    color: var(--nav-text);
    border-color: rgba(255,255,255,0.3);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }

.btn-danger {
    background: #d9534f;
    color: #fff;
    border-color: #d9534f;
}
.btn-danger:hover { background: #c9302c; text-decoration: none; color: #fff; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }

/* ===== Alerts ===== */
.alert {
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: var(--status-red-bg);
    color: #9b3030;
    border: 1px solid var(--status-red);
}

.alert-success {
    background: var(--status-green-bg);
    color: #2d6b45;
    border: 1px solid var(--status-green);
}

.alert-warning {
    background: var(--status-yellow-bg);
    color: #7a6520;
    border: 1px solid var(--status-yellow);
}

/* ===== Navbar ===== */
.navbar {
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    height: 48px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    margin-right: 2rem;
    white-space: nowrap;
}

.navbar-menu {
    list-style: none;
    display: flex;
    gap: 0;
    height: 100%;
}

.navbar-menu > li {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.navbar-menu > li > a {
    color: var(--nav-text);
    padding: 0 1rem;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.navbar-menu > li > a:hover { opacity: 1; text-decoration: none; }

/* Dropdown */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    list-style: none;
    padding: 0.35rem 0;
    z-index: 200;
}

.dropdown-menu[style*="display: none"] { display: none !important; }
.dropdown-menu:not([style*="display: none"]) { display: block; }

.dropdown-menu li a {
    display: block;
    padding: 0.45rem 1rem;
    color: var(--text);
    font-size: 0.875rem;
}
.dropdown-menu li a:hover {
    background: var(--bg);
    text-decoration: none;
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-user {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ===== Content ===== */
.app-wrapper { min-height: 100vh; }

.content {
    padding: 1.25rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== Cards / Panels ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* ===== Tables ===== */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table.data-table th,
table.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

table.data-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table.data-table tr:hover { background: #f8fafc; }

/* ===== Status Indicators ===== */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-0 { background: var(--status-red); }   /* expirat */
.status-1 { background: var(--status-yellow); } /* luna curenta */
.status-2 { background: var(--status-green); }  /* valid */

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toolbar input,
.toolbar select {
    width: auto;
    min-width: 140px;
}

/* ===== Two column form layout ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 1.5rem;
}

@media (max-width: 1024px) {
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

.form-grid .form-group-full {
    grid-column: 1 / -1;
}

/* ===== Inline form (for lookup tables) ===== */
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.inline-form .form-group { margin-bottom: 0; }

/* ===== Toast ===== */
#toast-container {
    position: fixed;
    top: 60px;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
}

.toast-success { background: var(--status-green-bg); color: #2d6b45; border: 1px solid var(--status-green); }
.toast-error { background: var(--status-red-bg); color: #9b3030; border: 1px solid var(--status-red); }

@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* ===== Tabulator overrides ===== */
.tabulator {
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.tabulator .tabulator-header {
    background: var(--bg) !important;
    border-bottom: 1px solid var(--border) !important;
}

.tabulator .tabulator-col {
    background: var(--bg) !important;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
    font-weight: 500;
}

/* ===== Inline form-group (label + control on same line) ===== */
.form-group-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.form-group-inline > label {
    margin-bottom: 0;
    white-space: nowrap;
    min-width: 110px;
}

/* ===== Radio Button Group ===== */
.radio-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: fit-content;
}

.radio-btn {
    display: block;
    margin: 0;
    cursor: pointer;
}

.radio-btn input[type="radio"] {
    display: none;
}

.radio-btn span {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    transition: all 0.15s;
    user-select: none;
}

.radio-btn:last-child span {
    border-right: none;
}

.radio-btn input[type="radio"]:checked + span {
    background: var(--primary);
    color: #fff;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    min-width: 320px;
    max-width: 480px;
}

.modal-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
}

/* ===== Utilities ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
