/* --- Google Fonts & Modern Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --primary-color: #3B82F6; /* Modern Mavi */
    --primary-hover-color: #2563EB;
    --background-color: #F3F4F6; /* Açık Gri Arkaplan */
    --sidebar-bg: #1F2937;
    --sidebar-text: #E5E7EB;
    --sidebar-active-bg: #374151;
    --content-bg: #FFFFFF;
    --text-color: #374151;
    --text-light: #6B7280;
    --border-color: #B6C6E3;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-radius: 14px;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 16px;
}

/* --- ANA YAPI (INDEX.PHP) --- */
.main-wrapper {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 180px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    min-width: 140px;
    transition: left 0.3s, box-shadow 0.3s;
    position: relative;
    z-index: 100;
    border-right: 2px solid var(--primary-color);
    box-shadow: 2px 0 12px rgba(59, 130, 246, 0.04);
    border-radius: 0 18px 18px 0 !important;
}

.sidebar-header {
    margin-bottom: 0.7rem;
}
.sidebar-header h3 {
    color: #fff;
    margin: 0;
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}
.sidebar-header .user-role {
    font-size: 0.75rem;
    color: var(--text-light);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.28rem 0.4rem;
    border-radius: 0.3rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 0.10rem;
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 0.85rem;
}
.menu-item:hover {
    background-color: var(--sidebar-active-bg);
}
.menu-item .menu-icon {
    margin-right: 0.7rem;
    font-size: 1rem;
    width: 18px;
}
.menu-item.logout-item {
    margin-top: auto;
    border-top: 1px solid var(--sidebar-active-bg);
    padding-top: 1rem;
}
.menu-divider {
    height: 1px;
    background-color: var(--sidebar-active-bg);
    margin: 0.35rem 0;
}
.menu-section-title {
    font-size: 0.62rem;
    text-transform: uppercase;
    color: var(--text-light);
    padding: 0 0.4rem;
    margin: 0.3rem 0 0.10rem;
}

.content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    border-left: 2px solid var(--primary-color);
    box-shadow: -2px 0 12px rgba(59, 130, 246, 0.04);
    border-radius: 18px 0 0 18px !important;
}

/* Tab Navigation Styles */
.nav-tabs {
    padding: 0 !important;
    background-color: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.nav-tabs .nav-item {
    list-style: none;
    margin-right: 2px;
    flex-shrink: 0;
}
.nav-tabs .nav-link {
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--primary-color);
    border-bottom: none;
    border-radius: 14px 14px 0 0 !important;
    background: linear-gradient(90deg, #f3f4f6 0%, #e0e7ef 100%);
    color: var(--primary-color);
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    margin-right: 4px;
}
.nav-tabs .nav-link.active {
    background: #fff;
    color: var(--primary-hover-color);
    border-bottom: 2.5px solid #fff;
}
.tab-close {
    margin-left: 0.75rem;
    color: #9CA3AF;
    font-weight: bold;
}
.tab-close:hover { color: var(--danger-color); }

/* Iframe Content Area */
.tab-contents-container {
    flex-grow: 1;
    position: relative;
}
.tab-content {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    background-color: var(--background-color);
    border: 1.5px solid var(--primary-color);
    border-radius: 16px !important;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.06);
}
.tab-content.active { display: block; }
.tab-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- IFRAME İÇİ GENEL STİLLER --- */
.container {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    border: 1.5px solid var(--primary-color);
    border-radius: 12px !important;
    background: var(--content-bg);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.05);
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin: 0 0 1.5rem 0;
}
h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tables */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--content-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--primary-color);
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.05);
}
th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #e0e7ef;
}
thead th {
    background-color: #F9FAFB;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #F9FAFB; }

.stock-low { color: var(--warning-color); font-weight: 500; }
.stock-critical { color: var(--danger-color); font-weight: 600; }
.profit { color: var(--success-color); }
.loss { color: var(--danger-color); }

/* Forms */
form {
    background: var(--content-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--primary-color);
    margin-top: 1rem;
    border: 1.5px solid var(--primary-color);
    border-radius: 14px !important;
    background: #f9fbfd;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.06);
}
.dashboard-section {
    background: var(--content-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-top: 1.5rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(59 130 246 / 0.3);
}
.form-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 200px; }

/* Buttons */
.button, button {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}
.button-primary, button[type="submit"] { background-color: var(--primary-color); }
.button-primary:hover, button[type="submit"]:hover { background-color: var(--primary-hover-color); }

.button-success { background-color: var(--success-color); }
.button-success:hover { background-color: #059669; }

.button-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* Alerts */
.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.375rem;
    font-weight: 500;
}
.alert-success { color: #065F46; background-color: #D1FAE5; border: 1px solid #A7F3D0; }
.alert-danger { color: #991B1B; background-color: #FEE2E2; border: 1px solid #FECACA; }

/* Dashboard Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}
.card {
    background: var(--content-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1.5px solid var(--primary-color);
    border-radius: 16px !important;
    background: linear-gradient(135deg, #f3f4f6 60%, #e0e7ef 100%);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.09);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.card h3, .card h4 {
    margin-top: 0;
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}
.card p {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0.5rem 0 0;
}
.card p.profit { color: var(--success-color); }
.card p.loss { color: var(--danger-color); }

/* Parçalar Listesi Grid */
.parts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem 0;
}
.part-card {
    background: var(--content-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1.5px solid var(--primary-color);
    border-radius: 16px !important;
    background: linear-gradient(135deg, #f3f4f6 60%, #e0e7ef 100%);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.09);
}
.part-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}
.part-image {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background-color: #F9FAFB;
    padding: 0.5rem;
}
.part-info { padding: 1rem; flex-grow: 1; display: flex; flex-direction: column; }
.part-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; }
.part-details { font-size: 0.875rem; color: var(--text-light); line-height: 1.6; }
.part-details div { margin-bottom: 4px; }
.part-actions { display: flex; gap: 0.75rem; margin-top: auto; padding-top: 1rem; }
.part-actions a { flex: 1; text-align: center; }

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}
.login-box {
    padding: 40px;
    background-color: var(--content-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1.5px solid var(--primary-color);
    border-radius: 18px !important;
    background: #fff;
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.10);
}
.login-box h2 {
    font-weight: 700;
    margin-bottom: 10px;
}
.login-box .sub-title {
    color: var(--text-light);
    margin-bottom: 30px;
}
.login-box .input-group {
    margin-bottom: 20px;
    text-align: left;
}
.login-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}
.login-box input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
}
.login-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}
.login-box button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    margin-top: 10px;
}
.login-box button:hover {
    background-color: var(--primary-hover-color);
}
.login-box .error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
}

/* Sidebar ve ana yapı için responsive düzenleme */
@media (max-width: 900px) {
    .main-wrapper {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        left: -180px;
        top: 0;
        height: 100vh;
        box-shadow: 2px 0 8px rgba(0,0,0,0.08);
        transition: left 0.3s;
    }
    .sidebar.active {
        left: 0;
    }
    .content-wrapper {
        margin-left: 0;
    }
    .sidebar-toggle-btn {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 200;
        background: var(--primary-color);
        color: #fff;
        border: none;
        border-radius: 50%;
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .sidebar-toggle-btn.bottom-right {
        position: fixed;
        bottom: 24px;
        right: 24px;
        left: auto;
        top: auto;
        z-index: 200;
        background: var(--primary-color);
        color: #fff;
        border: none;
        border-radius: 50%;
        width: 56px;
        height: 56px;
        font-size: 2rem;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s, color 0.2s;
    }
    .menu-item {
        font-size: 0.82rem;
        padding: 0.38rem 0.5rem;
        margin-bottom: 0.12rem;
    }
    .menu-section-title {
        font-size: 0.6rem;
        margin: 0.4rem 0 0.12rem;
        padding: 0 0.5rem;
    }
    .container {
        padding: 0.6rem;
        max-width: 100vw;
        border-width: 1px;
        border-radius: 8px !important;
        font-size: 0.97rem;
    }
    h2 {
        font-size: 1.1rem;
    }
    h3, h4 {
        font-size: 1rem;
    }
    .parts-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 8px 0;
    }
    .part-card {
        border-radius: 6px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    }
    .part-image {
        height: 120px;
    }
    .part-info {
        padding: 8px;
    }
    .part-title {
        font-size: 1rem;
        margin-bottom: 6px;
    }
    .part-details {
        font-size: 0.82em;
    }
    .part-actions a {
        font-size: 0.82em;
        padding: 6px;
    }
    table {
        font-size: 0.85em;
        width: 100%;
        display: block;
        overflow-x: auto;
        border-radius: 6px;
    }
    th, td {
        padding: 6px 4px;
    }
    .dashboard-section {
        padding: 0.5rem 0;
    }
    .summary-cards {
        flex-direction: column;
        gap: 8px;
    }
    .card {
        padding: 0.7rem;
        border-radius: 8px;
    }
    .card h3, .card h4 {
        font-size: 1rem;
    }
    .card p {
        font-size: 1rem;
    }
}
@media (min-width: 901px) {
    .sidebar-toggle-btn {
        display: none;
    }
}

/* Sidebar gizle/göster butonu */
.sidebar-hide-btn {
    position: absolute;
    top: 10px;
    right: -18px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 201;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.2s, color 0.2s;
}
.sidebar-hide-btn:hover {
    background: var(--primary-hover-color);
    color: #fff;
}

/* Sidebar gizli iken */
.sidebar.collapsed {
    width: 48px;
    min-width: 48px;
    padding: 0.5rem 0.2rem;
    overflow-x: hidden;
}
.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .user-role,
.sidebar.collapsed span {
    display: none !important;
}
.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 0.5rem 0.2rem;
}
.sidebar.collapsed .menu-item .menu-icon {
    margin-right: 0;
}
@media (max-width: 900px) {
    .sidebar {
        width: 180px;
        min-width: 140px;
    }
    .sidebar.collapsed {
        width: 0;
        min-width: 0;
        padding: 0;
    }
}

/* Sidebar alt logo alanı */
.sidebar-logo-container {
    margin-top: auto;
    padding: 1.2rem 0 0.5rem 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: 60px;
}
.sidebar-logo {
    max-width: 80px;
    max-height: 48px;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0.92;
    transition: max-width 0.2s, max-height 0.2s;
}
.sidebar.collapsed .sidebar-logo {
    max-width: 36px;
    max-height: 28px;
}

/* Badge (Rozet) Stilleri */
.badge {
    display: inline-block;
    padding: 0.35em 0.7em;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 0.35em;
    line-height: 1;
    vertical-align: baseline;
    text-align: center;
    white-space: nowrap;
}
.badge-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}
.badge-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}