:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --sidebar-width: 250px;
    --header-height: 60px;
    --notification-height: 80px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    color: #2c3e50;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 999;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    color: var(--primary-color);
}

.profile-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background var(--transition-speed);
}

.profile-btn:hover {
    background: #2980b9;
    color: white;
    text-decoration: none;
}

.logout-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background var(--transition-speed);
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary-color);
    color: white;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo img {
    max-width: 150px;
    height: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.menu-item {
    margin-bottom: 5px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all var(--transition-speed);
    cursor: pointer;
}

.menu-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.menu-link.active {
    background: var(--secondary-color);
    color: white;
    border-left: 4px solid white;
}

.menu-link i {
    width: 20px;
    margin-right: 15px;
    font-size: 16px;
}

.menu-link .menu-arrow {
    margin-left: auto;
    transition: transform var(--transition-speed);
}

.menu-link .menu-arrow.open {
    transform: rotate(90deg);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed);
    background: rgba(0,0,0,0.2);
}

.submenu.open {
    max-height: 500px;
}

.submenu-link {
    display: block;
    padding: 10px 20px 10px 55px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition-speed);
}

.submenu-link:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.submenu-link.active {
    color: white;
    background: rgba(255,255,255,0.15);
}

/* Disabled Menu Items */
.menu-link.menu-disabled,
.submenu-link.menu-disabled {
    opacity: 0.5;
    color: rgba(255,255,255,0.3) !important;
    cursor: not-allowed;
    pointer-events: none;
}

.menu-link.menu-disabled:hover,
.submenu-link.menu-disabled:hover {
    background: none !important;
    color: rgba(255,255,255,0.3) !important;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    margin-bottom: var(--notification-height);
    padding: 30px;
    min-height: calc(100vh - var(--header-height) - var(--notification-height));
}

/* Notifications Bar */
.notifications-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--notification-height);
    background: white;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 30px;
    z-index: 998;
}

.notification-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: transform var(--transition-speed);
}

.notification-item:hover {
    transform: translateY(-2px);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
}

.notification-icon.unread {
    background: var(--secondary-color);
    color: white;
}

.notification-icon.total {
    background: var(--success-color);
    color: white;
}

.notification-icon.warnings {
    background: var(--warning-color);
    color: white;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-color);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
}

.notification-label {
    font-size: 12px;
    color: #7f8c8d;
    font-weight: 500;
}

.notification-count {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

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

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-speed);
}

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

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

.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;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    max-width: 150px;
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 30px;
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .header,
    .notifications-bar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.form-grid .wide-field {
    grid-column: span 2;
}

.form-grid .form-group {
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.form-group .input-group {
    width: 100%;
    max-width: 100%;
}

/* Autocomplete Styles */
.autocomplete-container {
    position: relative;
    width: 100%;
    overflow: visible !important;
}

.autocomplete-field {
    width: 100%;
}

.autocomplete-list {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 99999 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 0;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-in-out;
}

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

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
}

.modal-close:hover,
.modal-close:focus {
    opacity: 0.7;
}

.modal-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Autocomplete in modals */
.modal .autocomplete-container {
    position: relative !important;
    overflow: visible !important;
}

.modal .autocomplete-list {
    position: fixed !important;
    z-index: 100000 !important;
}

/* Autocomplete moved to body from modal */
.autocomplete-in-body {
    position: fixed !important;
    z-index: 100000 !important;
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 150px);
    overflow-y: auto !important;
    overflow-x: visible !important;
}

.modal-body .form-grid {
    overflow: visible !important;
}

.modal-body .form-group {
    overflow: visible !important;
}

/* Dark theme support for modals */
[data-theme="dark"] .modal-content {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .modal-header {
    background-color: var(--primary-color);
}

[data-theme="dark"] .modal-footer {
    background-color: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .autocomplete-list {
    background: var(--card-bg);
    border-color: var(--border-color);
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

[data-theme="dark"] .autocomplete-item {
    color: var(--text-color);
    border-bottom-color: var(--border-color);
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

[data-theme="dark"] .autocomplete-item:hover {
    background-color: rgba(102, 126, 234, 0.2);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-no-results,
.autocomplete-error {
    padding: 10px 15px;
    color: #666;
    font-style: italic;
}

[data-theme="dark"] .autocomplete-no-results,
[data-theme="dark"] .autocomplete-error {
    color: #999;
}
