@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Georgian:wght@400;500;600;700&display=swap');

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e2a3a;
    --sidebar-text: #c8d3e0;
    --sidebar-active: #3b82f6;
    --sidebar-hover: #2d3f55;
    --accent: #3b82f6;
}

html, body {
    font-family: 'Noto Sans Georgian', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    height: 100%;
    margin: 0;
}

/* ===== Layout ===== */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    background: #f4f6f9;
    padding: 1.5rem;
}

/* ===== Sidebar brand ===== */
.sidebar-brand {
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid #2d3f55;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.brand-logo { height: 32px; width: auto; flex-shrink: 0; object-fit: contain; border-radius: 4px; }
.login-brand-logo { height: 80px; width: auto; object-fit: contain; margin-bottom: 0.5rem; }

/* ===== Desktop sidebar toggle ===== */
.sidebar-toggle-input { display: none; }
.mobile-close { display: none; }
.toggle-closed { display: none; }

.sidebar-toggle-btn {
    margin-left: auto;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--sidebar-text);
    font-size: 0.65rem;
    flex-shrink: 0;
    user-select: none;
}
.sidebar-toggle-btn:hover { background: var(--sidebar-hover); color: #fff; }

/* ===== Nav ===== */
.nav-list {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.nav-list li.nav-section {
    padding: 0.7rem 1rem;
    margin-top: 0.3rem;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    color: #e4ebf4;
    font-weight: 700;
    border-top: 1px solid #2d3f55;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}
.nav-list li.nav-section:hover { color: #fff; background: var(--sidebar-hover); }
.nav-list li.nav-section:not(.is-collapsed) { color: #fff; }
.nav-list li.nav-section:first-child { border-top: none; margin-top: 0; }

.nav-section-chevron {
    font-size: 1.15rem;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
    transform: rotate(90deg);
    transition: transform 0.2s ease;
}
.nav-section.is-collapsed .nav-section-chevron {
    transform: rotate(0deg);
}

.nav-icon {
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
}
.nav-text { white-space: nowrap; }

.nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s;
    overflow: hidden;
}
.nav-list .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-list .nav-link.active { background: var(--sidebar-active); color: #fff; }

/* ===== Sidebar footer ===== */
.sidebar-footer {
    border-top: 1px solid #2d3f55;
    padding: 0.75rem 1rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.user-icon { font-size: 1.5rem; }
.user-fullname { font-size: 0.8rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.7rem; color: #6b7f97; }

.logout-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.35rem;
    border-radius: 6px;
    background: #2d3f55;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.15s;
}
.logout-btn:hover { background: #c0392b; color: #fff; }

/* ===== Mobile topbar (hidden on desktop) ===== */
.mobile-topbar {
    display: none;
    align-items: center;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 0 1rem;
    height: 52px;
    gap: 0.75rem;
    flex-shrink: 0;
    border-bottom: 1px solid #2d3f55;
}
.mobile-hamburger {
    font-size: 1.4rem;
    cursor: pointer;
    color: #fff;
    user-select: none;
    line-height: 1;
    padding: 0.3rem;
    flex-shrink: 0;
}
.mobile-brand {
    font-weight: 700;
    font-size: 1rem;
    flex: 1;
}
.mobile-logout {
    font-size: 1.2rem;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.3rem;
    flex-shrink: 0;
}
.mobile-logout:hover { color: #fff; }

/* Mobile backdrop (hidden on desktop) */
.mobile-backdrop { display: none; }

/* ===== Desktop collapsed sidebar ===== */
.sidebar-toggle-input:checked ~ .app-wrapper .sidebar { width: 56px; }

.sidebar-toggle-input:checked ~ .app-wrapper .brand-name,
.sidebar-toggle-input:checked ~ .app-wrapper .nav-text,
.sidebar-toggle-input:checked ~ .app-wrapper .sidebar-footer,
.sidebar-toggle-input:checked ~ .app-wrapper .nav-section { display: none; }

.sidebar-toggle-input:checked ~ .app-wrapper .sidebar-brand {
    justify-content: center;
    padding: 1.25rem 0;
}
.sidebar-toggle-input:checked ~ .app-wrapper .brand-logo { margin: 0; }
.sidebar-toggle-input:checked ~ .app-wrapper .sidebar-toggle-btn { margin-left: 0; }
.sidebar-toggle-input:checked ~ .app-wrapper .toggle-open { display: none; }
.sidebar-toggle-input:checked ~ .app-wrapper .toggle-closed { display: inline; }
.sidebar-toggle-input:checked ~ .app-wrapper .nav-link {
    justify-content: center;
    padding: 0.6rem 0;
}

/* ===== Page header ===== */
.page-header {
    margin-bottom: 1.25rem;
}
.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

/* ===== Stat cards ===== */
.stat-card {
    border-radius: 10px;
    padding: 1.25rem;
    color: white;
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; opacity: 0.9; margin-top: 0.2rem; }

.stat-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-link:hover {
    color: inherit;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.stat-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-green  { background: linear-gradient(135deg, #10b981, #059669); }
.stat-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-red    { background: linear-gradient(135deg, #ef4444, #b91c1c); }

/* ===== Cards ===== */
.card { border: none; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border-radius: 8px; }
.card-header { background: #fff; border-bottom: 1px solid #eee; font-weight: 600; padding: 0.75rem 1rem; border-radius: 8px 8px 0 0 !important; }
.card-footer { background: #fafafa; border-top: 1px solid #eee; }

/* ===== Tables ===== */
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; }
.table td { vertical-align: middle; }

/* ===== Login ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a3a 0%, #2d3f55 100%);
    padding: 1rem;
}
.login-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h2 { font-weight: 700; margin: 0.5rem 0 0; }

/* ===== Project cards ===== */
.project-card { transition: box-shadow 0.15s; }
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

/* ===== Modal overlay ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-dialog-custom {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ===== Misc ===== */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; font-size: 0.8rem; }

#blazor-error-ui {
    background: #c0392b;
    bottom: 0; left: 0; right: 0;
    padding: 0.75rem 1rem;
    position: fixed;
    color: white;
    z-index: 9999;
    display: none;
}
#blazor-error-ui .reload { color: #ffd; margin-left: 1rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ===== MOBILE (≤ 767px) ===== */
@media (max-width: 767px) {

    /* Show mobile topbar */
    .mobile-topbar { display: flex; }

    /* Sidebar: fixed overlay, hidden off-screen by default */
    .sidebar {
        position: fixed !important;
        left: -290px;
        top: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 200;
        transition: left 0.25s ease !important;
    }

    /* Sidebar open: slide in */
    .sidebar-toggle-input:checked ~ .app-wrapper .sidebar {
        left: 0;
        width: 280px !important;
    }

    /* Override desktop collapse styles so sidebar shows full content when open */
    .sidebar-toggle-input:checked ~ .app-wrapper .brand-name { display: inline !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .nav-text    { display: inline !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .sidebar-footer { display: block !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .nav-section { display: list-item !important; }

    .sidebar-toggle-input:checked ~ .app-wrapper .sidebar-brand {
        justify-content: flex-start !important;
        padding: 1.25rem 1rem !important;
    }
    .sidebar-toggle-input:checked ~ .app-wrapper .sidebar-toggle-btn { margin-left: auto !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .nav-link {
        justify-content: flex-start !important;
        padding: 0.55rem 1rem !important;
    }

    /* Show X (close) icon, hide desktop arrows */
    .sidebar-toggle-input:checked ~ .app-wrapper .toggle-open   { display: none !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .toggle-closed { display: none !important; }
    .sidebar-toggle-input:checked ~ .app-wrapper .mobile-close  { display: inline !important; }

    /* Backdrop */
    .mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
        cursor: pointer;
    }
    .sidebar-toggle-input:checked ~ .mobile-backdrop { display: block; }

    /* Content area takes full width */
    .content-area { width: 100%; }

    /* Reduce padding */
    .main-content { padding: 0.75rem; }

    /* Page header: wrap on small screens */
    .page-header {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.75rem;
    }
    .page-header h1 { font-size: 1.1rem; }

    /* Smaller table text */
    .table { font-size: 0.8rem; }
    .table th { font-size: 0.7rem; }

    /* Stat card values smaller */
    .stat-value { font-size: 1.5rem; }
    .stat-card { padding: 0.9rem 0.75rem; }

    /* Smaller login card */
    .login-card { padding: 1.5rem 1.25rem; border-radius: 12px; }

    /* Touch-friendly buttons */
    .btn { min-height: 38px; }
    .btn-lg { min-height: 46px; font-size: 0.95rem; }

    /* Modal full screen on very small */
    .modal-overlay { padding: 0.5rem; align-items: flex-end; }
    .modal-dialog-custom { max-height: 95vh; border-radius: 12px 12px 0 0; }
    .modal-dialog-custom .card { border-radius: 12px 12px 0 0; }

    /* Card header: smaller padding */
    .card-header { padding: 0.6rem 0.75rem; font-size: 0.9rem; }
    .card-body { padding: 0.75rem; }

    /* Form controls: larger touch targets */
    .form-control, .form-select { min-height: 40px; font-size: 0.9rem; }
    .form-control-sm, .form-select-sm { min-height: 34px; }
}

/* ===== Product Photos ===== */
.photo-thumb-wrap {
    position: relative;
    width: 130px;
    flex-shrink: 0;
}

.photo-thumb {
    width: 130px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    cursor: zoom-in;
    transition: border-color 0.15s, transform 0.15s;
    display: block;
}
.photo-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}

.photo-thumb-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    font-size: 0.75rem;
    border-radius: 50%;
    border: none;
    background: rgba(220,53,69,0.85);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.photo-thumb-wrap:hover .photo-thumb-del { opacity: 1; }

/* ===== Lightbox ===== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 8px;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #333;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-name { color: #ccc; }

/* ===== Material List — photo thumbnail ===== */
.list-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    display: block;
    margin: auto;
}

.list-thumb-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin: auto;
}

.list-thumb-empty {
    font-size: 1.3rem;
    opacity: 0.2;
    display: block;
    text-align: center;
}

/* shimmer loading effect */
@keyframes shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 400px 100%;
    animation: shimmer 1.2s infinite linear;
}

/* ===== Photo thumb — star (main) button ===== */
.photo-thumb-star {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    font-size: 0.85rem;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.photo-thumb-star.is-main {
    color: #fbbf24;
    opacity: 1 !important;
    background: rgba(0,0,0,0.45);
}
.photo-thumb-wrap:hover .photo-thumb-star { opacity: 1; }
.photo-thumb-wrap:hover .photo-thumb-star:hover { color: #fbbf24; }

.photo-thumb-main .photo-thumb {
    border-color: #fbbf24;
    border-width: 2px;
}

/* ===== MaterialSelect — ჩამოსაშლელი სია ძებნით ===== */
.material-select-panel { background: var(--bs-body-bg); }
.material-select-list { max-height: 300px; overflow-y: auto; }
.material-select-group {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
    position: sticky; top: 0;
}
.material-select-item {
    padding: 0.3rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
}
.material-select-item .unit { color: var(--bs-secondary-color); }
.material-select-item:hover { background: var(--bs-secondary-bg); }
.material-select-item.active { background: var(--bs-primary); color: #fff; }
.material-select-item.active .unit { color: rgba(255,255,255,0.75); }
