/* ==========================================================================
   SULTAN FONTS — DESIGN SYSTEM 2026 (REFACTOR & OPTIMIZED)
   ========================================================================== */

   :root {
    --bg-main: #141414;
    --bg-card: #1f1f1f;
    --bg-input: #292929;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --primary: #00a896;
    --primary-hover: #02c3b3;
    --success: #2ec4b6;
    --danger: #e63946;
    --warning: #ffb703;
    --paypal: #0070ba;
    --border-radius: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   1. General Reset & Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'SFDroobVF', system-ui, -apple-system, sans-serif;
    font-display: swap;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    font-family: 'SFDroobVF', sans-serif;
    font-weight: 700;
}

p {
    font-family: 'SFDroobVF', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   2. Font Definitions
   -------------------------------------------------------------------------- */
@font-face {
    font-family: 'SFDroobVF';
    src: url('fonts/SFDroobVF.woff2') format('woff2');
    font-weight: 100 900;
    font-stretch: 100% 900%;
    font-style: oblique 0deg 15deg;
    font-display: swap;
}

@font-face {
    font-family: "SFLogo Regular";
    src: url("fonts/SFLogoVF.woff2") format("woff2");
    font-weight: 100 900;
    font-stretch: 100% 900%;
    font-style: oblique 0deg 15deg;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   3. Navigation & Brand Header
   -------------------------------------------------------------------------- */
nav {
    width: 100%;
    background-color: var(--bg-card);
    padding: 15px 20px;
    border-bottom: 1px solid #2d2d2d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    text-decoration: none;
    color: var(--text-main);
    display: inline-block;
    padding: 5px 10px;
    letter-spacing: 0.5px;
    transition: var(--transition);
}

.logo:hover, .logo:focus {
    color: var(--primary);
    transform: scale(1.02);
}

.logo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.logo-wrapper .tilde {
    display: inline-block;
    font-family: "SFLogo Regular", sans-serif;
    min-width: 35px;
    text-align: center;
    vertical-align: middle;
    font-size: 28px;
    line-height: 1;
    --wght: 100;
    --wdth: 50;
    font-variation-settings: "wght" var(--wght), "wdth" var(--wdth);
    animation: tilde-stretch 5s ease-in-out infinite;
}

.logo-wrapper .logo-text {
    display: inline-block;
    vertical-align: middle;
    font-family: "SFLogo Regular", sans-serif;
    font-size: 24px;
    font-weight: 900;
}

@keyframes tilde-stretch {
    0%, 100% { 
        font-variation-settings: "wght" 300, "wdth" 60; 
        opacity: 0.9;
    }
    50% { 
        font-variation-settings: "wght" 800, "wdth" 180; 
        color: var(--primary);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   4. Layout Layout Containers & Cards
   -------------------------------------------------------------------------- */
main.container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border: 1px solid #2d2d2d;
    width: 100%;
}

section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
    padding-left: 10px;
    text-align: left;
}

html[dir="rtl"] section h2 {
    border-left: none;
    border-right: 4px solid var(--primary);
    padding-right: 10px;
    text-align: right;
}

/* --------------------------------------------------------------------------
   5. Form Elements & Inputs
   -------------------------------------------------------------------------- */
.selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

select, input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid #3d3d3d;
    border-radius: var(--border-radius);
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

select:focus, input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.2);
}

select[multiple] {
    grid-column: span 2;
    height: 120px;
}

button#addFont {
    grid-column: span 2;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

button#addFont:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   6. Customer Info Fields
   -------------------------------------------------------------------------- */
.customer-info-section {
    margin-top: 30px;
    border-top: 1px dashed #2d2d2d;
    padding-top: 25px;
}

.customer-info-section h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--text-main);
}

.customer-info-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-bottom: 25px;
}

.customer-info-grid select {
    width: 80px;
}

html[dir="rtl"] .customer-info-grid input { text-align: right; direction: rtl; }
html[dir="ltr"] .customer-info-grid input { text-align: left; direction: ltr; }

/* --------------------------------------------------------------------------
   7. Tables & Financial UI
   -------------------------------------------------------------------------- */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

html[dir="rtl"] table {
    text-align: right;
}

th, td {
    padding: 14px;
    border-bottom: 1px solid #2d2d2d;
    font-size: 15px;
}

th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-weight: 600;
}

.total-card {
    background: rgba(0, 168, 150, 0.05);
    border: 1px solid rgba(0, 168, 150, 0.2);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 20px;
}

.total-card .price-big {
    font-size: 24px;
    color: var(--success);
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.badge-license {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   8. Payment Buttons Engine
   -------------------------------------------------------------------------- */
.payment-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.payment-buttons button {
    flex: 1;
    min-width: 160px;
    padding: 14px 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.payment-buttons button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-paypal { background: var(--paypal); border-color: var(--paypal) !important; }
.btn-bank { background: var(--primary); border-color: var(--primary) !important; }
.btn-western { background: var(--warning); color: #141414 !important; border-color: var(--warning) !important; }

/* --------------------------------------------------------------------------
   9. Modern Modals UI
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 15px;
}

.modal-content {
    background: #ffffff;
    color: #1a1a1a;
    width: 100%;
    max-width: 480px;
    border-radius: 16px;
    padding: 25px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.3s ease-out;
}

html[dir="rtl"] .modal-content { text-align: right; direction: rtl; }
html[dir="ltr"] .modal-content { text-align: left; direction: ltr; }

@keyframes modalIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    top: 15px;
    font-size: 26px;
    cursor: pointer;
    color: #888;
    transition: var(--transition);
}

html[dir="rtl"] .close { left: 15px; right: auto; }
html[dir="ltr"] .close { right: 15px; left: auto; }
.close:hover { color: var(--danger); }

/* --------------------------------------------------------------------------
   10. Interactive Chat Widget
   -------------------------------------------------------------------------- */
#chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    border-radius: 50%;
    color: #fff;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: var(--transition);
}

#chat-icon:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

#chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    color: #1a1a1a;
    z-index: 1000;
    border: 1px solid #e0e0e0;
}

.chat-header {
    background-color: var(--primary);
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

#close-chat {
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.8;
    transition: 0.2s;
}
#close-chat:hover { opacity: 1; }

.chat-body { padding: 15px; }

#chat-message {
    resize: none;
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-family: 'SFDroobVF', sans-serif;
    font-size: 0.95rem;
    outline: none;
}
#chat-message:focus { border-color: var(--primary); }

.chat-footer { padding: 0 15px 15px 15px; }

#send-message {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'SFDroobVF', sans-serif;
    font-weight: bold;
    transition: var(--transition);
}

#send-message:hover {
    background-color: var(--primary-hover);
}

/* --------------------------------------------------------------------------
   11. Internationalization Utilities & Responsiveness
   -------------------------------------------------------------------------- */
.hidden { display: none !important; }

html[dir="rtl"] .en-text { display: none !important; }
html[dir="ltr"] .ar-text { display: none !important; }

@media screen and (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: 10px;
    }
    .customer-info-grid {
        grid-template-columns: 1fr;
    }
    #chat-window {
        right: 10px;
        width: calc(100% - 20px);
    }
}

@media screen and (max-width: 600px) {
    .selector-grid { grid-template-columns: 1fr; }
    select[multiple], button#addFont { grid-column: span 1; }
    .payment-buttons button { width: 100%; flex: none; }

    /* تحويل محتوى الجداول التفاعلية لبطاقات عرض رأسية مريحة للجوال */
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr {
        background: #262626;
        border: 1px solid #333;
        border-radius: var(--border-radius);
        margin-bottom: 15px;
        padding: 10px;
    }
    td { 
        border: none;
        border-bottom: 1px solid #333; 
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
    }
    html[dir="rtl"] td {
        padding-left: 14px !important;
        padding-right: 50% !important;
        text-align: left !important;
    }
    td:last-child { border-bottom: 0; }
    td:before { 
        position: absolute; top: 14px; left: 14px; width: 45%; 
        white-space: nowrap; text-align: left; font-weight: bold; color: var(--text-muted);
    }
    html[dir="rtl"] td:before { left: auto; right: 14px; text-align: right; }
    
    td:nth-of-type(1):before { content: "#"; }
    td:nth-of-type(2):before { content: "Font"; }
    td:nth-of-type(3):before { content: "Weight"; }
    td:nth-of-type(4):before { content: "USD"; }
    td:nth-of-type(5):before { content: "SAR"; }
    td:nth-of-type(6):before { content: "Action"; }

    /* معالجة النوافذ المنبثقة لتظهر كـ Mobile Bottom Sheet */
    .modal { align-items: flex-end; padding: 0; }
    .modal-content {
        border-radius: 20px 20px 0 0;
        max-width: 100%;
        animation: sheetIn 0.3s ease-out;
    }
    @keyframes sheetIn {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}