/* Ühtne platvormi stiil */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Hele teema (Light) */
    --bg-color: #f0f2f5;
    --text-primary: #333333;
    --text-secondary: #555555;
    
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --border-color: #cccccc;
    
    --input-bg: #ffffff;
    --input-text: #333333;
    --input-focus: #007bff;
    
    --btn-primary: #007bff;
    --btn-primary-hover: #0069d9;
    --btn-text: #ffffff;
    
    --alert-success-bg: #e8fbe8;
    --alert-success-border: #8bc34a;
    --alert-success-text: #2e7d32;
    
    --alert-error-bg: #fdeaea;
    --alert-error-border: #f44336;
    --alert-error-text: #c62828;
    
    /* Külgmenüü & Päis (mõjutab sisemisi lehti) */
    --sidebar-bg: #2c3e50;
    --sidebar-header-bg: #1a252f;
    --sidebar-text: #bdc3c7;
    --sidebar-text-hover: #ffffff;
    --sidebar-item-border: #34495e;
    --sidebar-item-hover: #34495e;
    
    --topbar-bg: #ffffff;
    --topbar-text: #333333;
    --topbar-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

[data-theme="dark"] {
    /* Tume teema (Dark) */
    --bg-color: #121212;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    
    --card-bg: #1e1e1e;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.5);
    --border-color: #333333;
    
    --input-bg: #2d2d2d;
    --input-text: #e0e0e0;
    --input-focus: #4dabf7;
    
    --btn-primary: #1971c2;
    --btn-primary-hover: #1864ab;
    --btn-text: #ffffff;
    
    --alert-success-bg: rgba(46, 125, 50, 0.2);
    --alert-success-border: #4caf50;
    --alert-success-text: #81c784;
    
    --alert-error-bg: rgba(198, 40, 40, 0.2);
    --alert-error-border: #e53935;
    --alert-error-text: #e57373;
    
    --sidebar-bg: #181818;
    --sidebar-header-bg: #111111;
    --sidebar-text: #aaaaaa;
    --sidebar-text-hover: #ffffff;
    --sidebar-item-border: #222222;
    --sidebar-item-hover: #2a2a2a;
    
    --topbar-bg: #1e1e1e;
    --topbar-text: #e0e0e0;
    --topbar-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* Globaalne kastimudel hoiab paigutuse paigal */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Login / Forgot / Reset / Installer konteiner */
.login-container, .installer {
    width: 90%;
    max-width: 420px;
    margin: 80px auto;
    background: var(--card-bg);
    padding: 35px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.login-title, h1 {
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* Vormid */
.login-form label, label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 15px;
    display: block;
    font-weight: bold;
}

.login-form input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
    font-family: inherit;
    box-sizing: border-box;
}

.login-form input:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--input-focus);
}

/* Nupud */
.btn-primary, button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: var(--btn-primary);
    border: none;
    border-radius: 8px;
    color: var(--btn-text);
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-primary:hover, button[type="submit"]:hover {
    background: var(--btn-primary-hover);
}

/* Alertid */
.alert, .error, .success {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.4;
}

.alert.success, .success {
    background: var(--alert-success-bg);
    border: 1px solid var(--alert-success-border);
    color: var(--alert-success-text);
}

.alert.error, .error {
    background: var(--alert-error-bg);
    border: 1px solid var(--alert-error-border);
    color: var(--alert-error-text);
}

/* Lingid */
.login-links {
    text-align: center;
    margin-top: 15px;
}

.login-links a {
    color: var(--input-focus);
    text-decoration: none;
    font-size: 14px;
}

.login-links a:hover {
    text-decoration: underline;
}

/* Kliendiportaali & Admin Paneeli Layout (Responsivne) */
.dashboard-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    font-size: 20px;
    font-weight: bold;
    background: var(--sidebar-header-bg);
    text-align: center;
    border-bottom: 1px solid var(--sidebar-item-border);
    transition: background-color 0.3s ease;
    color: var(--sidebar-text-hover);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: block;
    padding: 15px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-item-border);
    transition: background 0.2s, color 0.2s;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-hover);
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.topbar {
    background: var(--topbar-bg);
    color: var(--topbar-text);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--topbar-shadow);
    transition: background-color 0.3s ease, color 0.3s ease;
    z-index: 10;
}

/* Hamburger & Teema lüliti ikoonid */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--topbar-text);
    font-size: 24px;
    cursor: pointer;
    margin-right: 15px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--topbar-text);
    font-size: 20px;
    cursor: pointer;
    margin-right: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.logout-btn {
    margin-left: 15px;
    color: var(--alert-error-border);
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s, opacity 0.2s;
}

.logout-btn:hover {
    opacity: 0.8;
}

.topbar-right {
    display: flex;
    align-items: center;
}

.content-area {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 25px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.card h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    color: var(--text-primary);
}

/* Tabelite responsiivsus */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-responsive table {
    white-space: nowrap;
}

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

th, td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    color: var(--text-primary);
}

th {
    background: rgba(0,0,0,0.05);
    font-weight: 600;
}

[data-theme="dark"] th {
    background: rgba(255,255,255,0.05);
}

/* Mobiilne paigutus */
@media (max-width: 992px) {
    .login-container, .installer {
        margin: 40px auto;
        padding: 25px;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Overlay kui menüü on lahti */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .menu-toggle {
        display: inline-block;
    }
    
    .topbar {
        padding: 15px 20px;
    }
    
    .content-area {
        padding: 15px;
    }
    
    .card, .dash-box, .admin-card {
        padding: 15px !important;
    }

    .topbar {
        flex-wrap: wrap;
    }
    .topbar-page-title {
        width: 100%;
        order: 3;
        text-align: center;
        margin-top: 10px;
        padding-top: 10px;
        font-size: 16px;
        border-top: 1px solid var(--sidebar-item-border);
    }
}

@media (max-width: 500px) {
    .user-greeting {
        display: none !important;
    }
    .logout-text {
        display: none !important;
    }
}

/* Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: 35px;
    right: -10px;
    width: 280px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    animation: fadeInDown 0.2s ease-out;
}
.notification-dropdown.active {
    display: flex;
}
.notification-header {
    padding: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.notification-item {
    display: flex;
    align-items: center;
    padding: 15px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}
.notification-item:last-child {
    border-bottom: none;
}
.notification-item:hover {
    background: var(--bg-color);
}
.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}
.notification-text {
    display: flex;
    flex-direction: column;
}
.notification-text strong {
    font-size: 14px;
}
.notification-text span {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Logout Modal */
.logout-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}
.logout-modal-overlay.active {
    display: flex;
}
.logout-modal-box {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: fadeInScale 0.2s ease-out;
}
.logout-modal-box h3 {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 20px;
}
.logout-modal-box p {
    color: var(--text-secondary);
    margin-bottom: 25px;
}
.logout-modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}
.logout-modal-actions .btn-cancel {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.logout-modal-actions .btn-cancel:hover {
    background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .logout-modal-actions .btn-cancel:hover {
    background: rgba(255,255,255,0.05);
}
.logout-modal-actions .btn-confirm {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background: #e53935;
    color: white;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.logout-modal-actions .btn-confirm:hover {
    background: #c62828;
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}