/* ===================================================
   YAKLAŞIK MALİYET PROGRAMI — MAIN STYLESHEET
   =================================================== */

:root {
    --navy: #1E3A5F;
    --primary: #2D6AA0;
    --primary-dark: #1668c1;
    --accent: #0ea5e9;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --light-bg: #f0f4f8;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
}

/* ============ BASE ============ */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--light-bg);
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.25;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

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

.btn-outline:hover:not(:disabled) {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

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

.btn-danger:hover:not(:disabled) {
    background-color: #b91c1c;
    border-color: #b91c1c;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.375rem;
}

/* ============ FORM ELEMENTS ============ */

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.input-field {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 160, 0.15);
}

.input-field:read-only {
    background: #f8fafc;
    color: var(--text-secondary);
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

/* ============ MODALS ============ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    backdrop-filter: blur(2px);
    padding: 1rem;
}

.modal-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modal-appear 0.15s ease;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
}

.modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: #f8fafc;
    border-radius: 0 0 1rem 1rem;
}

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

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

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table thead th {
    background: #f1f5f9;
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table thead th.text-right {
    text-align: right;
}

.data-table thead th.text-center {
    text-align: center;
}

.data-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}

.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr:hover {
    background: #eff6ff !important;
}

.data-table tbody tr.selected-row {
    background: #dbeafe !important;
    outline: 1px solid #93c5fd;
    outline-offset: -1px;
}

.data-table tbody td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    color: var(--text-primary);
}

.data-table tbody td.text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Consolas', 'Courier New', monospace;
}

.data-table tfoot td {
    padding: 0.75rem;
}

/* Analysis tree specific rows */
.data-table .group-row {
    background: #e8edf5 !important;
}

.data-table .group-row:hover {
    background: #dce4f0 !important;
}

.data-table .group-row.selected-row {
    background: #bfdbfe !important;
}

.data-table .group-row td {
    font-weight: 600;
    color: var(--navy);
    padding: 0.625rem 0.75rem;
}

.data-table .item-row td {
    padding: 0.4375rem 0.75rem;
}

/* ============ SIDEBAR ============ */

.sidebar {
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px !important;
    min-width: 60px !important;
}

.sidebar.collapsed .sidebar-text {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.625rem;
}

.sidebar.collapsed .nav-link i {
    width: auto;
    margin: 0;
}

.sidebar.collapsed #sidebar-toggle i {
    transform: rotate(180deg);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15) !important;
    color: white;
}

.nav-link.active i {
    color: var(--accent) !important;
}

/* ============ PAGE SECTIONS ============ */

.page-section {
    display: none;
}

.page-section.active {
    display: flex !important;
}

/* ============ CATALOG ITEMS ============ */

.catalog-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
    position: relative;
}

.catalog-item:hover {
    background: #f8fafc;
}

.catalog-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--primary);
}

.catalog-item .delete-btn {
    display: none;
    position: absolute;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    color: var(--danger);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
}

.catalog-item:hover .delete-btn {
    display: flex;
}

.catalog-item .delete-btn:hover {
    background: #fee2e2;
}

/* ============ AUTHORITY BADGES ============ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge-dsi {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-ib {
    background: #dcfce7;
    color: #15803d;
}

.badge-csb {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge-nakliye {
    background: #ffedd5;
    color: #c2410c;
}

.badge-ozel {
    background: #f1f5f9;
    color: #475569;
}

.badge-diger {
    background: #f1f5f9;
    color: #475569;
}

/* ============ ANALYSIS LIST ITEMS ============ */

.analysis-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
    gap: 0.5rem;
}

.analysis-item:hover {
    background: #f8fafc;
}

.analysis-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--primary);
}

.analysis-item .poz-no {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    font-family: 'Consolas', monospace;
}

.analysis-item .name {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ UPLOAD AREAS ============ */

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 0.75rem;
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

/* ============ LOADING OVERLAY ============ */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(2px);
}

/* ============ TOAST NOTIFICATIONS ============ */

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 400px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: toast-in 0.3s ease;
    cursor: pointer;
}

.toast-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.toast-error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #be123c;
}

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

.toast-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0c4a6e;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 100px;
    }
    to {
        opacity: 0;
        transform: translateX(20px);
        max-height: 0;
        margin: 0;
        padding: 0;
    }
}

.toast.removing {
    animation: toast-out 0.3s ease forwards;
}

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

.welcome-card {
    outline: none;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.welcome-card:hover {
    transform: translateY(-2px);
}

.welcome-card:focus {
    box-shadow: 0 0 0 3px rgba(45, 106, 160, 0.25);
}

/* ============ INLINE EDIT ============ */

.inline-edit-input {
    border: 1px solid var(--primary);
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.8125rem;
    width: 100%;
    outline: none;
    font-family: inherit;
}

.inline-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(45, 106, 160, 0.2);
}

/* ============ PAGINATION ============ */

.page-btn {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    font-size: 0.8125rem;
    cursor: pointer;
    background: white;
    color: var(--text-primary);
    transition: all 0.1s;
}

.page-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

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

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============ LIBRARY PANEL ============ */

.library-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.library-item:hover {
    background: #f8fafc;
}

/* ============ CONTEXT MENU ============ */

#context-menu {
    animation: ctx-appear 0.1s ease;
}

@keyframes ctx-appear {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ============ ANALYSIS ITEMS (editable row) ============ */

.quantity-cell {
    cursor: pointer;
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    transition: background 0.1s;
}

.quantity-cell:hover {
    background: #eff6ff;
    outline: 1px solid #93c5fd;
}

/* ============ EMPTY STATES ============ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 50;
        transform: translateX(-100%);
    }

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

    .catalog-left-panel {
        width: 220px !important;
        min-width: 220px !important;
    }
}

/* ============ PRINT ============ */

@media print {
    .sidebar,
    header,
    .btn,
    #toast-container,
    #context-menu {
        display: none !important;
    }
}

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

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.font-mono {
    font-family: 'Consolas', 'Courier New', monospace;
}

.rotate-180 {
    transform: rotate(180deg);
}

/* Action buttons in table rows */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.row-action-btn {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.1s, color 0.1s;
    color: var(--text-secondary);
}

.row-action-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.row-action-btn.danger:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* Catalog selected highlight */
.catalog-item.active .catalog-info {
    color: var(--primary);
}

/* Numeric display cells */
.num-cell {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8125rem;
    text-align: right;
    white-space: nowrap;
}

/* Suggestion dropdown */
#item-poz-suggestions .suggestion-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}

#item-poz-suggestions .suggestion-item:hover {
    background: #eff6ff;
}

#item-poz-suggestions .suggestion-item .poz {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    font-family: monospace;
}

#item-poz-suggestions .suggestion-item .tarif {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Position table row selection */
.positions-row.selected-row {
    background: #dbeafe !important;
}

/* Grand total row */
#positions-total-row td {
    background: var(--navy);
}

/* PDF warnings */
.pdf-warning-item {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: #92400e;
}

/* Category badges */
.cat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
}

.cat-genel { background: #f1f5f9; color: #475569; }
.cat-boru { background: #dbeafe; color: #1d4ed8; }
.cat-sanat { background: #f3e8ff; color: #7e22ce; }
.cat-nakliye { background: #ffedd5; color: #c2410c; }
