@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* "Automotive Pro" Palette */
    --primary-color: #0284c7;
    /* Sky 600 - Reliable, Pro Blue */
    --primary-hover: #0369a1;
    /* Sky 700 */

    --sidebar-bg: #0f172a;
    /* Slate 900 - Deep Dark */
    --sidebar-text: #e2e8f0;
    /* Slate 200 - High legibility */
    --sidebar-active: #38bdf8;
    /* Sky 400 - Brigther accent */

    --secondary-color: #64748b;
    /* Slate 500 - Mechanical/Grey */
    --success-color: #059669;
    /* Emerald 600 */
    --info-color: #0ea5e9;
    /* Sky 500 */
    --warning-color: #d97706;
    /* Amber 600 */
    --danger-color: #dc2626;
    /* Red 600 */

    --dark-color: #1e293b;
    /* Slate 800 */
    --light-color: #f8fafc;
    /* Slate 50 */
    --body-bg: #f1f5f9;
    /* Slate 100 */
    --card-bg: #ffffff;
    --border-color: #cbd5e1;
    /* Slate 300 - Crisp borders */

    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--body-bg);
    color: var(--dark-color);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

/* ===========================
   Layout Structure
   =========================== */
#wrapper {
    display: flex;
    overflow-x: hidden;
    width: 100%;
}

#content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-color: var(--body-bg);
    min-height: 100vh;
}

/* ===========================
   Sidebar Styles
   =========================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg) !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    list-style: none;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-brand {
    height: 4.5rem;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    color: #fff !important;
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand-icon {
    color: var(--primary-color);
    margin-right: 0.75rem;
    font-size: 1.5rem;
}

.sidebar .nav-item {
    position: relative;
    margin: 2px 10px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar .nav-link i {
    font-size: 1rem;
    margin-right: 0.75rem;
    width: 1.5rem;
    text-align: center;
    opacity: 0.7;
}

/* Arrow for Collapse Items */
.sidebar .nav-link[data-bs-toggle="collapse"]::after {
    content: '\f105';
    /* fa-angle-right */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.3s;
    opacity: 0.5;
}

.sidebar .nav-link[data-bs-toggle="collapse"]:hover::after {
    opacity: 1;
}

.sidebar .nav-link[data-bs-toggle="collapse"]:not(.collapsed)::after {
    transform: rotate(90deg);
    color: #fff;
    opacity: 1;
}

/* Active State */
.sidebar .nav-item.active .nav-link {
    color: #fff;
    background-color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2), 0 2px 4px -1px rgba(239, 68, 68, 0.1);
}

.sidebar .nav-item.active .nav-link i {
    opacity: 1;
}

.sidebar-heading {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    /* Lighter Slate for better contrast on dark bg */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar hr.sidebar-divider {
    margin: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.5;
}

/* Submenu / Collapse Styles */
.sidebar .collapse-inner {
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.5rem 0;
    margin: 0.5rem 0 1rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.2s;
}

.sidebar .collapse-item {
    color: var(--secondary-color);
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar .collapse-item:hover {
    background-color: var(--body-bg);
    color: var(--primary-color);
    padding-left: 1.5rem;
    /* Slight slide effect */
}

.sidebar .collapse-item.active {
    color: var(--primary-color);
    font-weight: 700;
    background-color: #eff6ff;
}

.sidebar .collapse-header {
    margin: 0;
    padding: 0.5rem 1.25rem;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 0.65rem;
    color: #cbd5e1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Sidebar Toggled (Collapsed) */
.sidebar.toggled {
    width: 6.5rem !important;
    overflow: visible;
}

.sidebar.toggled .sidebar-brand-text,
.sidebar.toggled .sidebar-heading {
    display: none;
}

.sidebar.toggled .nav-link {
    flex-direction: column;
    text-align: center;
    padding: 1rem 0.5rem;
    font-size: 0.75rem;
}

.sidebar.toggled .nav-link i {
    margin-right: 0;
    margin-bottom: 0.25rem;
    font-size: 1.25rem;
}

.sidebar.toggled .nav-link span {
    display: block;
    /* Show text below icon if needed, or hide */
    font-size: 0.7rem;
}

.sidebar.toggled .nav-link::after {
    display: none;
    /* Hide arrow in mini mode */
}

/* Hide collapsing menu items in mini mode to avoid popup issues or Handle it */
.sidebar.toggled .collapse {
    /* In a real mini-sidebar, submenus usually become popovers. 
       For simplicity, we might just letting it be or hiding it.
       SB Admin 2 standard behavior puts it in absolute position. 
       Let's stick to basic hide or simple overlay if needed.
    */
    position: absolute;
    left: 6.5rem;
    top: auto;
    margin: 0;
    width: 12rem;
    z-index: 1000;
}

.sidebar.toggled .collapse-inner {
    margin: 0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}


/* ===========================
   Components
   =========================== */
.topbar {
    height: 4.5rem;
    background-color: #fff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: relative;
    z-index: 900;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: #334155;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-dark {
    background-color: var(--dark-color);
    border-color: var(--dark-color);
    color: #fff;
}

/* Utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.text-gray-800 {
    color: var(--dark-color) !important;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

.border-left-primary {
    border-left: 4px solid var(--primary-color) !important;
}

.border-left-success {
    border-left: 4px solid var(--success-color) !important;
}

.border-left-info {
    border-left: 4px solid var(--info-color) !important;
}

.border-left-warning {
    border-left: 4px solid var(--warning-color) !important;
}

.border-left-danger {
    border-left: 4px solid var(--danger-color) !important;
}


/* ===========================
   Mobile Responsiveness
   =========================== */
@media (max-width: 768px) {

    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 0;
        /* Starte hidden size */
        overflow: hidden;
        transform: translateX(-100%);
        /* Slide out */
        z-index: 1050;
        /* Above everything */
        transition: transform 0.3s ease-in-out;
        display: block;
        /* Ensure it's rendered but hidden */
    }

    /* Show sidebar when active */
    .sidebar.toggled {
        transform: translateX(0) !important;
        /* Force Slide in */
        width: 250px !important;
        overflow-y: auto;
        /* Scrollable */
    }

    /* Restore normal nav link layout in mobile even when toggled */
    .sidebar.toggled .nav-link {
        flex-direction: row;
        text-align: left;
        padding: 0.75rem 1rem;
    }

    .sidebar.toggled .nav-link i {
        margin-right: 0.75rem;
        margin-bottom: 0;
        font-size: 1rem;
    }

    .sidebar.toggled .nav-link span {
        display: inline;
        font-size: 0.9rem;
    }

    .sidebar.toggled .sidebar-brand-text,
    .sidebar.toggled .sidebar-heading {
        display: flex;
        /* Restore brand and headings */
    }

    .sidebar.toggled .nav-link::after {
        display: block;
        /* Restore arrow in mobile menu */
    }

    .sidebar.toggled .collapse {
        position: relative;
        left: auto;
        width: 100%;
    }

    /* Overlay for clicking outside */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }

    body.sidebar-toggled .sidebar-overlay {
        display: block;
    }

    /* Wrapper adjustments */
    #wrapper {
        flex-direction: column;
    }

    /* Topbar adjustments */
    .topbar {
        padding: 0 1rem;
        justify-content: space-between;
    }
}

/* ===========================
   Responsive Table Cards
   =========================== */
@media (max-width: 991px) {
    .mobile-table-cards thead {
        display: none;
    }
    .mobile-table-cards tbody tr {
        display: block;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 1.5rem;
        padding: 1rem;
        background: #fff;
        position: relative;
    }
    .mobile-table-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none !important;
        padding: 0.6rem 0.25rem;
        border-bottom: 1px dashed #f1f5f9 !important;
        min-height: 45px;
    }
    .mobile-table-cards tbody td:last-child {
        border-bottom: none !important;
        padding-top: 1rem;
        justify-content: center;
        background: #fff2f2;
        margin: 0.5rem -1rem -1rem -1rem;
        border-radius: 0 0 12px 12px;
    }
    .mobile-table-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #64748b;
        font-size: 0.7rem;
        text-transform: uppercase;
        margin-right: 1rem;
        flex-shrink: 0;
        width: 100px;
    }
    
    .mobile-table-cards .select2-container {
        width: 100% !important;
        flex-grow: 1;
    }
    .mobile-table-cards input, 
    .mobile-table-cards select {
        width: 100% !important;
        max-width: 200px;
        text-align: right !important;
    }

    /* Full width fields */
    .mobile-table-cards td[data-label="Ürün / Hizmet"],
    .mobile-table-cards td[data-label="Açıklama"],
    .mobile-table-cards td[data-label="Hizmet / Ürün Adı"] {
        flex-direction: column;
        align-items: stretch;
    }
    .mobile-table-cards td[data-label="Ürün / Hizmet"]::before,
    .mobile-table-cards td[data-label="Açıklama"]::before,
    .mobile-table-cards td[data-label="Hizmet / Ürün Adı"]::before {
        width: 100%;
        margin-bottom: 0.4rem;
    }
    .mobile-table-cards td[data-label="Ürün / Hizmet"] input,
    .mobile-table-cards td[data-label="Açıklama"] input,
    .mobile-table-cards td[data-label="Hizmet / Ürün Adı"] input {
        max-width: 100%;
        text-align: left !important;
    }

    /* Remove column labels in footer */
    .mobile-table-cards tfoot td::before {
        display: none;
    }
    .mobile-table-cards tfoot tr {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 1rem;
    }
    .mobile-table-cards tfoot td {
        display: block;
        padding: 0;
        border: none !important;
    }
}