/* 
   الهوية البصرية لنظام حسابات المقهى (ملاذ القهوة)
   تصميم أعمال احترافي ومسطح (Professional Flat Business Design)
*/

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

:root {
    --coffee-primary: #3E2723;
    --coffee-secondary: #5D4037;
    --coffee-accent: #F5F0EB;
    
    --bg-main: #F7F5F3;
    --bg-card: #FFFFFF;
    
    --text-main: #2D2926;
    --text-secondary: #6D6560;
    --text-muted: #A09890;
    
    --border-color: #E5E0DB;
    --border-light: #F0EDEA;
    
    --green: #1B7A3D;
    --green-light: #EBF5EE;
    --red: #C0392B;
    --red-light: #FCEAE8;
    --yellow: #D4850A;
    --yellow-light: #FEF6E8;
    --blue: #2874A6;
    --blue-light: #E8F0F8;
    
    --shadow-subtle: 0 1px 3px rgba(0,0,0,0.06);
    --radius-card: 6px;
    --radius-elem: 4px;
    --transition-fast: 150ms ease;
}

[data-theme="dark"] {
    --bg-main: #1A1614;
    --bg-card: #242019;
    --text-main: #E8E3DE;
    --text-secondary: #9C958E;
    --text-muted: #6D6560;
    --border-color: #332D28;
    --border-light: #2A2420;
    --coffee-accent: #2A2420;
}

* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Cairo', -apple-system, sans-serif;
    font-size: 14px;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    direction: rtl;
    text-align: right;
    padding-top: 60px; /* 48px header + 12px gap */
    padding-bottom: 70px; /* 56px nav + 14px gap */
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* 1. التخطيط الأساسي (Layout) */
.app-header,
.mobile-top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--coffee-primary);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1040;
    border-bottom: 1px solid var(--coffee-secondary);
}

.app-brand,
.mobile-top-header .brand-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #FFFFFF;
    text-decoration: none;
}

.btn-header-icon {
    background: transparent;
    border: none;
    color: #FFFFFF;
    font-size: 1.1rem;
    padding: 6px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
}
.btn-header-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.app-bottom-nav,
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-tab,
.nav-item-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    flex: 1;
    height: 100%;
    transition: color var(--transition-fast);
}

.nav-tab i,
.nav-item-mobile i {
    font-size: 1.1rem;
    margin-bottom: 3px;
}

.nav-tab.active,
.nav-item-mobile.active {
    color: var(--coffee-secondary);
    font-weight: 700;
}

.nav-tab:hover,
.nav-item-mobile:hover {
    color: var(--text-main);
}

/* 2. البطاقات (Cards) */
.card-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-subtle);
}

/* 3. الإحصائيات (Stat Cards) */
.stat-grid-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card-mobile {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 10px 12px;
    text-align: right;
    box-shadow: var(--shadow-subtle);
}

.stat-card-mobile .val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-card-mobile .lbl {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 4. بطاقات الموردين أو القوائم (List Cards) */
.supplier-card-mobile {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-card);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-main);
    margin-bottom: 8px;
    box-shadow: var(--shadow-subtle);
    transition: background-color var(--transition-fast);
}

.supplier-card-mobile:active {
    background-color: var(--bg-main);
}

.supplier-card-mobile .icon-box-mobile {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-elem);
    background: var(--coffee-accent);
    color: var(--coffee-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-left: 12px;
    flex-shrink: 0;
}

.supplier-card-mobile .info-box {
    flex-grow: 1;
}

.supplier-card-mobile .supplier-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.supplier-card-mobile .action-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 5. الجداول (Tables) */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text-main);
    font-size: 13px;
    border-collapse: collapse;
}

.table th {
    background-color: var(--bg-main);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

/* تحويل الجداول للهاتف (Mobile Tables) */
@media (max-width: 767.98px) {
    .table-mobile-cards {
        display: block;
    }
    
    .table-mobile-cards thead {
        display: none;
    }
    
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-cards tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-card);
        margin-bottom: 12px;
        padding: 8px 12px;
        box-shadow: var(--shadow-subtle);
    }
    
    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid var(--border-light);
        text-align: left;
    }
    
    .table-mobile-cards td:last-child {
        border-bottom: none;
    }
    
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-align: right;
    }
}

/* 6. النماذج والأزرار (Forms & Buttons) */
.form-control, .form-select {
    height: 38px;
    font-size: 14px;
    border-radius: var(--radius-elem);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--coffee-primary);
    box-shadow: 0 0 0 2px rgba(62,39,35,0.1);
    outline: none;
}

.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: var(--radius-elem);
    font-size: 14px;
    padding: 6px 16px;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    border: 1px solid transparent;
}

.btn-coffee {
    background-color: var(--coffee-primary);
    color: #FFFFFF !important;
}

.btn-coffee:hover, .btn-coffee:active {
    background-color: var(--coffee-secondary);
    color: #FFFFFF;
}

.btn-outline-coffee {
    border-color: var(--coffee-primary);
    color: var(--coffee-primary);
    background: transparent;
}

.btn-outline-coffee:hover {
    background-color: var(--coffee-accent);
}

.btn-paid {
    background-color: var(--green);
    color: #FFFFFF !important;
}

.btn-debt {
    background-color: var(--red);
    color: #FFFFFF !important;
}

/* 7. الشارات (Badges) */
.badge {
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-elem);
}

.badge-paid {
    background-color: var(--green-light);
    color: var(--green);
}

.badge-debt {
    background-color: var(--red-light);
    color: var(--red);
}

.badge-due {
    background-color: var(--yellow-light);
    color: var(--yellow);
}

/* 8. أدوات مساعدة (Utilities) */
.summary-bar {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    margin-bottom: 16px;
    box-shadow: var(--shadow-subtle);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

/* 9. النوافذ المنبثقة (Modals) */
.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-subtle);
}

.modal-header {
    background-color: var(--coffee-primary);
    color: #FFFFFF;
    border-bottom: none;
    border-radius: calc(var(--radius-card) - 1px) calc(var(--radius-card) - 1px) 0 0;
    padding: 12px 16px;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.8;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

/* 10. شريط التمرير (Scrollbar) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 11. الطباعة (Print) */
@media print {
    .no-print, .mobile-bottom-nav, .mobile-top-header, .btn {
        display: none !important;
    }
    body {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        background-color: #FFFFFF !important;
        color: #000000 !important;
    }
    .card-custom, .stat-card-mobile, .supplier-card-mobile {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
