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

body { font-family: 'Inter', sans-serif; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--color-slate-300); border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: var(--color-slate-600); }

/* Tabs */
.tab-btn.active { background-color: var(--color-white); color: var(--color-blue-600); border-bottom: 2px solid var(--color-blue-600); }
.dark .tab-btn.active { background-color: var(--color-slate-800); color: var(--color-blue-400); border-bottom: 2px solid var(--color-blue-400); }
.tab-btn { color: var(--color-slate-500); border-bottom: 2px solid transparent; }
.dark .tab-btn { color: var(--color-slate-400); }

/* Modal Tabs */
.modal-tab.active { border-bottom: 2px solid var(--color-blue-600); color: var(--color-blue-600); font-weight: bold; }
.dark .modal-tab.active { border-bottom: 2px solid var(--color-blue-400); color: var(--color-blue-400); }
.modal-tab { color: var(--color-slate-500); cursor: pointer; border-bottom: 2px solid transparent; }
.dark .modal-tab { color: var(--color-slate-400); }

/* Toast Notification */
.toast { 
    position: fixed; bottom: 90px; right: 20px; 
    background: var(--color-slate-800); color: var(--color-white); 
    padding: 12px 24px; border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
    transform: translateY(100px); opacity: 0; 
    transition: all 0.3s ease-out; z-index: 100; 
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Global Loader */
#globalLoader { 
    position: fixed; inset: 0; 
    background: rgba(255,255,255,0.8); 
    z-index: 9999; 
    display: none; 
    justify-content: center; align-items: center; flex-direction: column; 
    backdrop-filter: blur(2px); 
}
.dark #globalLoader { background: rgba(15, 23, 42, 0.9); }

.spinner { 
    width: 40px; height: 40px; 
    border: 4px solid var(--color-slate-200); 
    border-top: 4px solid var(--color-blue-600); 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
}
@keyframes spin {0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }}

/* Sync Button (FAB) */
.sync-fab {
    position: fixed; bottom: 20px; right: 20px; z-index: 90;
    display: flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: 99px; 
    color: var(--color-white); font-weight: bold; font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease; border: none; cursor: pointer;
}
.sync-clean { background-color: var(--color-blue-600); opacity: 0.8; }
.sync-dirty { background-color: #dc2626; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }

/* Print Styles */
@media print {
    @page { margin: 0.5cm; size: auto; }
    body > *:not(#printArea) { display: none !important; }
    body { background-color: white !important; color: black !important; height: auto !important; overflow: visible !important; }
    #printArea { display: block !important; position: relative !important; width: 100% !important; height: auto !important; left: 0 !important; top: 0 !important; background: white !important; color: black !important; padding: 0 !important; margin: 0 !important; visibility: visible !important; font-size: 12pt; }
    #printArea * { visibility: visible !important; color: black !important; background: transparent !important; border-color: #000 !important; }
    .no-print { display: none !important; }
}

/* Sorting Headers */
.sortable-header { cursor: pointer; user-select: none; transition: color 0.2s; }
.sortable-header:hover { color: var(--color-blue-600); }
.dark .sortable-header:hover { color: var(--color-blue-400); }
.sort-icon { display: inline-block; width: 10px; margin-left: 4px; opacity: 0.3; }
.sortable-header.active .sort-icon { opacity: 1; color: var(--color-blue-600); }
.dark .sortable-header.active .sort-icon { color: var(--color-blue-400); }

/* Form Helpers */
.lbl { display: block; font-size: 0.75rem; font-weight: 700; color: var(--color-slate-500); margin-bottom: 0.25rem; text-transform: uppercase; } 
.dark .lbl { color: var(--color-slate-400); } 
.inp { width: 100%; border: 1px solid var(--color-slate-300); padding: 0.5rem; border-radius: 0.375rem; font-size: 0.875rem; } 
.inp:focus { outline: none; border-color: var(--color-blue-500); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

/* Spec Tree Styles */
#specTreeContainer .fa-chevron-right,
#specTreeContainer .fa-chevron-down {
    transition: transform 0.2s ease;
}

#specTreeContainer > div {
    transition: background-color 0.2s ease;
}

/* Modal Animations */
.modal-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease-out, backdrop-filter 0.3s ease-out;
    backdrop-filter: blur(0px);
}

.modal-backdrop.show {
    opacity: 1;
    backdrop-filter: blur(8px);
}

.modal-content {
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease-out;
}

.modal-backdrop.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Help Navigation Styles */
.help-nav-btn {
    transition: all 0.2s ease;
}

.help-nav-btn.active {
    background-color: var(--color-blue-100);
    color: var(--color-blue-800);
    font-weight: 700;
}

.dark .help-nav-btn.active {
    background-color: var(--color-slate-700);
    color: var(--color-blue-400);
}

.help-nav-btn:hover {
    transform: translateX(4px);
}

/* Dropdown Menu */
#dropdownMenu {
    animation: fadeIn 0.2s ease-out;
}

#dropdownMenu button {
    border-bottom: 1px solid var(--color-slate-200);
}

.dark #dropdownMenu button {
    border-bottom-color: var(--color-slate-600);
}

#dropdownMenu button:last-child {
    border-bottom: none;
}

#dropdownMenu button.bg-blue-50,
#dropdownMenu button.dark\:bg-blue-900\/20 {
    font-weight: 600;
}

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

/* Контейнеры таблиц на панели дашборда для прокрутки */
#dashDeadlineTable,
#dashLowStockTable,
#dashLastMovTable {
    /* Таблицы будут иметь естественную высоту внутри контейнера с прокруткой */
}

/* Чеклист документации проекта */
.documentation-checkbox {
    flex-shrink: 0;
    outline: none;
    user-select: none;
}

.documentation-checkbox:focus {
    outline: 2px solid rgba(34, 197, 94, 0.5);
    outline-offset: 2px;
}

.documentation-checkbox.checked {
    animation: checkPulse 0.3s ease-out;
}

@keyframes checkPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Стили для диаграммы Ганта (кастомная реализация) */
#ganttContainer {
    width: 100%;
    max-height: 350px;
    overflow: auto;
}

.gantt-wrapper {
    min-width: 100%;
}

.gantt-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.gantt-label-cell {
    width: 720px;
    min-width: 720px;
    max-width: 720px;
    padding: 8px 12px;
    font-size: 13px;
    color: #334155;
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    left: 0;
    z-index: 9;
}

.dark .gantt-label-cell {
    color: #e2e8f0;
    border-right-color: #334155;
}

.gantt-label-num {
    font-weight: 700;
    font-size: 12px;
    color: #3b82f6;
    min-width: 60px;
    padding: 2px 6px;
    background-color: #dbeafe;
    border-radius: 4px;
    text-align: center;
}

.dark .gantt-label-num {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.gantt-label-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .gantt-label-name {
    color: #e2e8f0;
}

.gantt-bars-cell {
    position: relative;
    padding: 0;
}

.gantt-header-row {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #ffffff;
}

.dark .gantt-header-row {
    background-color: #1e293b;
}

.gantt-header-row .gantt-label-cell {
    height: 32px;
    vertical-align: bottom;
    position: sticky;
    left: 0;
    z-index: 11;
    background-color: #ffffff;
}

.dark .gantt-header-row .gantt-label-cell {
    background-color: #1e293b;
}

.gantt-header-row .gantt-bars-cell {
    height: 32px;
    border-bottom: 1px solid #e2e8f0;
}

.dark .gantt-header-row .gantt-bars-cell {
    border-bottom-color: #334155;
}

.gantt-timeline {
    position: relative;
    width: 100%;
    height: 100%;
}

.gantt-month {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: 0 8px 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    border-left: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.gantt-month:first-child {
    border-left: none;
}

.dark .gantt-month {
    color: #94a3b8;
    border-left-color: #334155;
}

.gantt-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.gantt-row:hover {
    background-color: #f8fafc;
}

.dark .gantt-row:hover {
    background-color: #1e293b;
}

.gantt-row .gantt-bars-cell {
    height: 32px;
    border-bottom: 1px solid #f1f5f9;
}

.dark .gantt-row .gantt-bars-cell {
    border-bottom-color: #1e293b;
}

.gantt-bars-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.gantt-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #e2e8f0;
}

.dark .gantt-grid-line {
    background-color: #334155;
}

.gantt-bar {
    position: absolute;
    height: 18px;
    top: 7px;
    border-radius: 3px;
    min-width: 4px;
}

.gantt-bar-project {
    background-color: #3b82f6;
    z-index: 1;
}

.gantt-bar-design {
    background-color: #f97316;
    z-index: 2;
}

.gantt-legend {
    display: flex;
    gap: 16px;
    padding: 10px 0 4px 0;
    font-size: 11px;
    color: #64748b;
}

.dark .gantt-legend {
    color: #94a3b8;
}

.gantt-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gantt-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.gantt-legend-project {
    background-color: #3b82f6;
}

.gantt-legend-design {
    background-color: #f97316;
}

/* Единые стили кнопок */
.btn-blue,
.btn-green,
.btn-red,
.btn-yellow,
.btn-purple {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 500;
    border-radius: 9999px;
    transition: all 0.3s ease;
    background-color: transparent;
}

.btn-blue {
    border: 2px solid var(--color-btn-blue);
    color: var(--color-btn-blue);
}

.btn-blue:hover {
    background-color: var(--color-btn-blue);
    color: white;
}

.btn-green {
    border: 2px solid var(--color-btn-green);
    color: var(--color-btn-green);
}

.btn-green:hover {
    background-color: var(--color-btn-green);
    color: white;
}

.btn-red {
    border: 2px solid var(--color-btn-red);
    color: var(--color-btn-red);
}

.btn-red:hover {
    background-color: var(--color-btn-red);
    color: white;
}

.btn-yellow {
    border: 2px solid #eab308;
    color: #eab308;
}

.btn-yellow:hover {
    background-color: #eab308;
    color: white;
}

.btn-purple {
    border: 2px solid #a855f7;
    color: #a855f7;
}

.btn-purple:hover {
    background-color: #a855f7;
    color: white;
}

/* Стили для маленьких кнопок с иконками */
.btn-blue.w-6,
.btn-green.w-6,
.btn-red.w-6 {
    padding: 0;
    min-width: 24px;
    min-height: 24px;
}

.btn-blue.w-6 i,
.btn-green.w-6 i,
.btn-red.w-6 i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 1;
}

/* Всплывающее увеличенное изображение */
.img-zoom-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 8px;
    max-width: 350px;
    max-height: 350px;
}

.dark .img-zoom-tooltip {
    background: var(--color-slate-800);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.img-zoom-tooltip.show {
    opacity: 1;
}

.img-zoom-tooltip img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* Эффект при наведении на изображение в таблице */
table img.cursor-pointer {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

table img.cursor-pointer:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}