/* =============================================
   DIRBTUVES.LT - Profesionali apskaitos sistema
   Versija: 2.0
   ============================================= */

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

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --success: #059669;
    --success-light: #10b981;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

html {
    font-size: 15px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

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

a:hover {
    color: var(--primary-dark);
}

/* =============================================
   LAYOUT
   ============================================= */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--gray-900);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-700);
    background: var(--gray-800);
}

.sidebar-header h1 {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    letter-spacing: -0.01em;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 0;
}

.nav-section {
    margin-bottom: 4px;
}

.nav-section-title {
    padding: 10px 16px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--gray-800);
    color: white;
    text-decoration: none;
}

.nav-link.active {
    background: var(--gray-800);
    color: white;
    border-left-color: var(--primary-light);
}

.nav-link-icon {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    background: var(--gray-50);
}

.top-bar {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.breadcrumb {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.content-area {
    padding: 20px 24px;
    max-width: 1400px;
}

/* =============================================
   CARDS
   ============================================= */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 18px;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--gray-200);
}

.stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: 1.2rem;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 18px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-700);
    transition: all 0.15s ease;
    border: 1px solid var(--gray-200);
}

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

.action-icon {
    font-size: 1.3rem;
}

.action-text {
    font-weight: 500;
    font-size: 0.85rem;
}

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

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

.btn-success:hover {
    background: #047857;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* =============================================
   FORMS
   ============================================= */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="tel"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: white;
    color: var(--gray-800);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* =============================================
   TABLES
   ============================================= */

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    font-size: 0.8rem;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* =============================================
   ALERTS
   ============================================= */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error,
.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* =============================================
   FILE GRID
   ============================================= */

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.file-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.file-card:hover {
    box-shadow: var(--shadow-md);
}

.file-thumb {
    height: 120px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-thumb-icon {
    font-size: 2.5rem;
    color: var(--gray-400);
}

.file-info {
    padding: 12px;
}

.file-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gray-800);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.file-actions {
    padding: 8px 12px 12px;
    display: flex;
    gap: 8px;
}

.file-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 6px 8px;
}

/* =============================================
   MOBILE MENU
   ============================================= */

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--gray-700);
    box-shadow: var(--shadow);
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

.sidebar-overlay.active {
    display: block;
}

/* =============================================
   UTILITIES
   ============================================= */

.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.font-bold { font-weight: 600; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.hidden { display: none !important; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* =============================================
   RESPONSIVE - MOBILE
   ============================================= */

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }

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

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

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

    .top-bar {
        padding: 14px 16px;
        padding-left: 60px;
    }

    .content-area {
        padding: 16px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .files-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .file-thumb {
        height: 100px;
    }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* =============================================
   TABLE SPECIAL STYLES (for history/apartment)
   ============================================= */

.section-border-left {
    border-left: 2px solid var(--gray-200);
}

.amount {
    font-weight: 600;
    color: var(--success);
}

.consumption {
    font-weight: 600;
    color: var(--primary-light);
}

.reading-from {
    color: var(--gray-400);
    font-size: 0.85em;
}

.reading-to {
    font-weight: 600;
}

/* Section backgrounds */
.heating-section { background: #fefce8; }
.gas-section { background: #fefce8; }
.hot-section { background: #fef2f2; }
.cold-section { background: #ecfdf5; }
.water-section { background: #eff6ff; }
.shared-section { background: var(--gray-50); }
.other-section { background: var(--gray-50); }
.total-section { background: #d1fae5; font-weight: 700; }

/* Quarter separator */
.data-table tbody tr.quarter-end td,
.apt-table tbody tr.quarter-end td,
.history-table tbody tr.quarter-end td {
    border-bottom: 2px solid var(--gray-300) !important;
}
