/* /public/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    --bg-body: #131314;
    --bg-card: #1E1F20;
    --bg-input: #2D2E30;
    --text-main: #E3E3E3;
    --text-muted: #9AA0A6;
    --accent-blue: #8AB4F8;
    --accent-gradient: linear-gradient(135deg, #1A73E8 0%, #8AB4F8 100%);
    --border-color: #3C4043;
    --success: #81C995;
    --danger: #F28B82;
    --radius: 12px;
    --sidebar-width: 250px;
}

* { box_sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Layout --- */
.wrapper { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    padding: 20px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.mobile-header {
    display: none;
    background-color: var(--bg-card);
    padding: 15px 20px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 99;
}

.main-content {
    flex: 1;
    padding: 30px;
    width: 100%;
    overflow-x: hidden;
}

h1, h2, h3 { margin-bottom: 20px; font-weight: 500; color: #fff; }

/* --- Components --- */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}

.form-group { margin-bottom: 24px; width: 100%; }
label { display: block; margin-bottom: 10px; color: var(--text-muted); font-size: 13px; font-weight: 500; }
input, select, textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 14px;
    color: var(--text-main);
    font-family: inherit;
    transition: 0.2s;
    font-size: 14px;
}

/* Фікси для Select та Date */
select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA0A6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; padding-right: 40px;
}
input[type="date"]::-webkit-calendar-picker-indicator { display: none; -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-blue); background-color: #353638; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border-radius: 8px; border: none; cursor: pointer;
    font-weight: 500; text-decoration: none; transition: 0.2s; font-size: 14px;
}
.btn i { margin-right: 0px; }
.btn-primary { background: var(--accent-gradient); color: #000; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background-color: var(--bg-input); color: var(--text-main); }
.btn-danger { background-color: rgba(242, 139, 130, 0.2); color: var(--danger); }

/* Navigation */
.nav-link {
    display: block; padding: 12px 16px; color: var(--text-muted); text-decoration: none;
    border-radius: var(--radius); margin-bottom: 8px; transition: all 0.2s; font-size: 15px;
}
.nav-link:hover, .nav-link.active { background-color: rgba(138, 180, 248, 0.1); color: var(--accent-blue); }
.nav-link i { margin-right: 10px; width: 20px; text-align: center; }
.logout-btn { margin-top: auto; color: var(--danger); }

/* Utilities */
.flex-row { display: flex; gap: 30px; align-items: flex-start; width: 100%; }
.text-right { text-align: right; }
.mb-2 { margin-bottom: 10px; }
.mt-4 { margin-top: 20px; }

/* Login & Modal */
.login-container { width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 400px; }
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 99;
}

/* Tables (Десктоп) */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
tr:hover td { background-color: rgba(255,255,255,0.02); }

/* Flatpickr & Trends */
.flatpickr-calendar, .flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year { background: var(--bg-card) !important; color: var(--text-main) !important; fill: var(--text-main) !important; }
.flatpickr-calendar { border: 1px solid var(--border-color) !important; box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important; }
.flatpickr-day { color: var(--text-main) !important; }
.flatpickr-day.selected, .flatpickr-day:hover, .flatpickr-day:focus { background: var(--accent-blue) !important; border-color: var(--accent-blue) !important; color: #000 !important; font-weight: bold; }
.flatpickr-weekday { color: var(--text-muted) !important; }

.filter-bar { background-color: var(--bg-card); border: 1px solid rgba(255,255,255,0.05); border-radius: var(--radius); padding: 15px; margin-bottom: 30px; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-end; }
.trend-indicator { font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; margin-top: 6px; }
.trend-up { color: var(--success); background: rgba(129, 201, 149, 0.1); }
.trend-down { color: var(--danger); background: rgba(242, 139, 130, 0.1); }
.trend-neutral { color: var(--text-muted); background: rgba(255,255,255,0.05); }

/* Modal Styles */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 2000; justify-content: center; align-items: center; overflow-y: auto; padding: 20px; }
.modal-box { width: 500px; max-width: 100%; background-color: var(--bg-card); border-radius: var(--radius); padding: 24px; border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); position: relative; animation: modalFadeIn 0.2s ease-out; }
@keyframes modalFadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   МОБІЛЬНА АДАПТАЦІЯ (Планшети і менше)
========================================= */
@media (max-width: 992px) {
    .mobile-header { display: flex; }
    .sidebar { position: fixed; left: -100%; width: 280px; height: 100%; box-shadow: 5px 0 15px rgba(0,0,0,0.5); }
    .sidebar.active { left: 0; }
    .sidebar-overlay.active { display: block; }
    .main-content { padding: 20px 15px; }
    .flex-row { flex-direction: column; gap: 20px; }
    .card { max-width: 100%; }
    .filter-actions { flex-direction: column; align-items: stretch; }
    .filter-bar .btn { width: 100%; justify-content: center; }
}

/* =========================================
   МОБІЛЬНА АДАПТАЦІЯ (Телефони - ГЛИБОКА СТИЛІЗАЦІЯ)
========================================= */
@media (max-width: 768px) {
    /* Кнопки на всю ширину */
    .btn { width: 100%; margin-bottom: 10px; }
    
    /* Картки статистики */
    .flex-row > .card {
        min-width: 100%;
        margin-bottom: 15px; /* Відступ між картками */
    }
    /* Зменшуємо шрифт величезних цифр на телефоні */
    .card div[style*="font-size: 28px"] { font-size: 24px !important; }

    /* --- ПЕРЕТВОРЕННЯ ТАБЛИЦЬ НА КАРТКИ (Дашборд і не тільки) --- */
    .card.table-responsive {
        background: transparent; /* Прибираємо фон контейнера */
        border: none;
        padding: 0;
    }
    .card.table-responsive table, 
    .card.table-responsive thead, 
    .card.table-responsive tbody, 
    .card.table-responsive th, 
    .card.table-responsive td, 
    .card.table-responsive tr { 
        display: block; /* Все стає блоками */
    }
    
    /* Ховаємо шапку таблиці */
    .card.table-responsive thead { display: none; }
    
    /* Стиль рядка як окремої картки */
    .card.table-responsive tr {
        background-color: var(--bg-card);
        border-radius: var(--radius);
        padding: 20px;
        margin-bottom: 15px; /* Відступ між "рядками"-картками */
        border: 1px solid rgba(255,255,255,0.05);
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
    
    /* Стиль комірок всередині картки */
    .card.table-responsive td {
        padding: 5px 0;
        border: none; /* Прибираємо лінії */
        text-align: left !important;
        position: relative;
    }

    /* Специфічні стилі для контенту в Дашборді */
    /* Перша комірка (Назва проєкту) - робимо її заголовком */
    .card.table-responsive tr td:first-child {
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    .card.table-responsive tr td:first-child div[style*="font-weight: 500"] {
        font-size: 18px; /* Збільшуємо назву */
    }
    
    /* Додаємо підписи до даних (Клієнт, Бюджет) через CSS content */
    .card.table-responsive tr td:nth-child(2)::before { content: "Клієнт: "; color: var(--text-muted); font-size: 12px; }
    .card.table-responsive tr td:nth-child(3)::before { content: "Бюджет: "; color: var(--text-muted); font-size: 12px; }
    
    /* Вирівнювання кнопок дій праворуч в інших таблицях */
    .text-right { text-align: left; margin-top: 10px; }
}

/* --- ФІКС: Інпути вилазять за межі модального вікна --- */

/* 1. Гарантуємо, що відступи не додаються до ширини */
input, select, textarea, .form-group, .modal-box {
    box-sizing: border-box !important;
}

/* 2. Обмежуємо максимальну ширину інпутів */
.modal-box input, 
.modal-box select, 
.modal-box textarea {
    max-width: 100%;
}

/* 3. Фікс для Flex-row всередині модалки на мобільному */
@media (max-width: 768px) {
    /* Робимо всі поля в модалці стовпчиком на телефоні */
    .modal-box .flex-row {
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
    }
    
    /* Змушуємо групи полів не виходити за межі */
    .modal-box .form-group {
        width: 100% !important;
        margin-bottom: 15px !important;
        margin-right: 0 !important;
    }
}

/* ================= LOGIN PAGE MOBILE STYLES ================= */

/* Контейнер на весь екран */
.login-container {
    width: 100%;
    min-height: 100vh; /* min-height краще ніж height, щоб на малих екранах можна було скролити */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at center, #1E1F20 0%, #0d0d0e 100%); /* Легкий градієнт */
}

/* Сама картка входу */
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    /* Тінь для ефекту глибини */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); 
}

/* Логотип */
.login-logo {
    height: 80px; /* Оптимальний розмір для десктопу */
    width: auto;
    margin-bottom: 10px;
}

/* Адаптація під мобільні телефони */
@media (max-width: 480px) {
    .login-container {
        padding: 15px;
        align-items: center; /* Центруємо по вертикалі */
    }

    .login-box {
        padding: 25px 20px; /* Менші відступи всередині */
        border: none; /* Можна прибрати рамку на телефоні для чистоти */
        background-color: var(--bg-card); /* Або залишити карткою */
    }

    .login-logo {
        height: 60px; /* Менший логотип на телефоні */
    }

    h2 {
        font-size: 20px !important; /* Менший заголовок */
    }
    
    /* Робимо поля вводу трішки вищими для зручного натискання пальцем */
    .login-box input {
        padding-top: 16px;
        padding-bottom: 16px;
    }
}

@media (max-width: 992px) {
 .filter-actions {
    gap: 14px;
}
.flex-row {
    display: flex;
    gap: 10px!important;
    align-items: normal;
}
.btn-edit {
    width: 50px;
}
}
/* ================= FIXES (Модалка та Клієнти) ================= */

/* 1. ФІКС МОДАЛКИ: Щоб інпути не вилазили за межі */
.modal-box, 
.modal-box * {
    box-sizing: border-box !important; /* Враховуємо рамки і відступи в ширину */
}

.modal-box input, 
.modal-box select, 
.modal-box textarea {
    width: 100%; 
    max-width: 100%; /* Забороняємо бути ширше за батька */
}

/* На мобільному, якщо два поля в рядок (Flex), даємо їм простір */
.modal-box .flex-row input, 
.modal-box .flex-row select {
    width: 100%;
    min-width: 0; /* Магія CSS, щоб флекс-елементи не розпирало */
}


/* 2. СТИЛІ ДЛЯ КАРТКИ КЛІЄНТА */

/* Контейнер для кнопок (щоб вони не прилипали) */
.client-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start; /* Притискаємо вліво, щоб не було на всю ширину */
}

/* Єдиний стиль для Телефону, ТГ та Пошти */
.client-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    color: var(--text-main);
    background-color: var(--bg-input); /* Темний фон як у полів вводу */
    border: 1px solid transparent;
    max-width: 100%; /* Щоб не вилазило на мобільному */
}

.client-btn i {
    margin-right: 10px;
    color: var(--text-muted);
}

.client-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Спеціальний колір для Telegram */
.client-btn.tg {
    background-color: rgba(42, 171, 238, 0.1);
    color: #2AABEE;
}
.client-btn.tg i { color: #2AABEE; }
.client-btn.tg:hover { background-color: rgba(42, 171, 238, 0.2); }

/* Спеціальний колір для Email */
.client-btn.email {
    border: 1px solid var(--border-color);
    background: transparent;
}