/* =============================================
   Cangir Plastik - Stok Yönetim Sistemi
   Industrial / Professional Design
   ============================================= */

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

:root {
    --bg-primary: #f4f5f7;
    --bg-card: #ffffff;
    --bg-sidebar: #12151a;
    --bg-sidebar-hover: #1e2128;
    --bg-sidebar-active: #262a33;

    --text-primary: #1a1d23;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --text-sidebar: #a0a4ab;
    --text-sidebar-active: #ffffff;

    --accent: #e8922a;
    --accent-light: #fef3e2;
    --accent-dark: #c67b1f;

    --success: #1a9e57;
    --success-light: #e6f7ee;
    --danger: #dc3545;
    --danger-light: #fde8ea;
    --info: #2f80ed;
    --info-light: #e8f0fd;
    --warning: #f0b429;
    --warning-light: #fef9e7;

    --border: #e2e5ea;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --sidebar-width: 260px;
    --header-height: 64px;

    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #12151a 0%, #1e2128 50%, #12151a 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: fadeUp 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.login-logo span {
    color: var(--accent);
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition);
    background: var(--bg-primary);
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

/* =============================================
   LAYOUT
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
}

.sidebar-header h1 span { color: var(--accent); }

.sidebar-header p {
    font-size: 0.72rem;
    color: var(--text-sidebar);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

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

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #ddd;
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-body {
    padding: 28px 32px;
    flex: 1;
}

/* Mobile menu toggle */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

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

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

.btn-success:hover { background: #158a48; }

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* =============================================
   CARDS
   ============================================= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.card-body { padding: 24px; }

.card-body.p-0 { padding: 0; }

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.orange { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info { flex: 1; }

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* =============================================
   TABLES
   ============================================= */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--bg-primary);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }

table tbody tr {
    transition: background var(--transition);
}

table tbody tr:hover { background: #f8f9fa; }

.item-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.item-thumb-placeholder {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.stock-ok { background: var(--success-light); color: var(--success); }
.stock-low { background: var(--warning-light); color: #9a7500; }
.stock-critical { background: var(--danger-light); color: var(--danger); }

.action-btns {
    display: flex;
    gap: 6px;
}

/* =============================================
   FORMS & MODALS
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.4rem;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}

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

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* BOM section in form */
.bom-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bom-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.bom-item:last-child { border-bottom: none; }

.bom-item select, .bom-item input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
}

.bom-item select { flex: 2; }
.bom-item input[type="number"] { flex: 1; width: 80px; }

.bom-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}

/* IMAGE UPLOAD */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.image-upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.image-upload-area img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
}

.image-upload-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.image-upload-text strong {
    color: var(--accent);
}

/* =============================================
   SEARCH & FILTERS
   ============================================= */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color var(--transition);
    background: #fff;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* =============================================
   HISTORY / TIMELINE
   ============================================= */
.timeline {
    padding: 0;
    list-style: none;
}

.timeline-item {
    display: flex;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.timeline-dot.add { background: var(--success); }
.timeline-dot.remove { background: var(--danger); }
.timeline-dot.sale { background: var(--info); }
.timeline-dot.start { background: var(--accent); }

.timeline-content { flex: 1; }

.timeline-text { font-size: 0.88rem; }
.timeline-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* =============================================
   SALE PREVIEW
   ============================================= */
.sale-preview {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

.sale-preview h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.deduction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.deduction-item:last-child { border-bottom: none; }

.deduction-arrow {
    color: var(--danger);
    font-weight: 700;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.4; }

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* =============================================
   TOAST / NOTIFICATIONS
   ============================================= */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent);
    font-size: 0.88rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }

/* =============================================
   TAB NAVIGATION
   ============================================= */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.tab:hover { color: var(--text-primary); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* =============================================
   LOADING
   ============================================= */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.page-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeUp 0.35s ease;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

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

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

    .mobile-toggle { display: flex; }

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

    .content-header { padding: 0 16px; }
    .content-body { padding: 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 1.2rem; }

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

    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }

    table th, table td { padding: 10px 12px; font-size: 0.82rem; }

    .modal { max-width: 100%; margin: 10px; }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        display: none;
    }

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

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .header-actions .btn span { display: none; }
}

/* =============================================
   UTILITY
   ============================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
