/* =================================
   1. General Layout & Structure
   ================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
    direction: rtl;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #2d3748;
    font-weight: 400;
    line-height: 1.6;
}

.app-container {
    display: flex;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    color: #e2e8f0;
    padding: 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar h3 {
    text-align: center;
    color: #ffffff;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    padding-bottom: 20px;
    margin-top: 5px;
    margin-bottom: 25px;
    font-size: 1.6em;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.sidebar ul {
    list-style-type: none;
    padding: 0;
    margin-top: 20px;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    color: #cbd5e1;
    font-size: 1.05em;
    font-weight: 500;
    padding: 16px 14px;
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.sidebar ul li a:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    color: #ffffff;
    border-right-color: #667eea;
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.main-content {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    margin: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

hr {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    margin: 35px 0;
    border-radius: 2px;
}

/* =================================
   2. Dashboard & Action Buttons
   ================================= */
.dashboard-stats, .quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.2);
}

.stat-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.1em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card p {
    font-size: 2.5em;
    font-weight: 700;
    color: #667eea;
    margin: 0;
    text-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.action-btn, .action-btn-secondary {
    display: inline-block;
    padding: 14px 28px;
    text-decoration: none;
    border: none;
    border-radius: 12px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: capitalize;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.action-btn::before, .action-btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.action-btn:hover::before, .action-btn-secondary:hover::before {
    left: 100%;
}

.action-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.action-btn-secondary {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(113, 128, 150, 0.3);
}

.action-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(113, 128, 150, 0.4);
}

/* =================================
   3. Tables & Forms
   ================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

th, td {
    padding: 16px 20px;
    text-align: right;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9em;
}

tr:nth-child(even) {
    background: rgba(102, 126, 234, 0.03);
}

tr:hover {
    background: rgba(102, 126, 234, 0.08);
    transition: background-color 0.3s ease;
}

.styled-form {
    max-width: 650px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
}

.styled-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea,
.form-group select,
.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 1em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
    position: relative;
    overflow: hidden;
}

.form-group button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.form-group button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.4);
}

.form-group button:hover::before {
    left: 100%;
}

/* =================================
   4. Point of Sale (POS)
   ================================= */
.pos-container {
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

.product-selection, .sale-cart {
    width: 50%;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
}

.product-selection::before, .sale-cart::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}
#search-results {
    margin-top: 20px;
    max-height: 450px;
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.search-item {
    padding: 15px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.search-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.search-item-none {
    padding: 15px;
    color: #718096;
    text-align: center;
    font-style: italic;
}

.pos-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.pos-actions button {
    flex-grow: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cart-summary-breakdown {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid rgba(102, 126, 234, 0.2);
    background: rgba(102, 126, 234, 0.05);
    padding: 20px;
    border-radius: 12px;
    margin-left: -25px;
    margin-right: -25px;
    margin-bottom: -25px;
}

.cart-summary-breakdown div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1.1em;
    font-weight: 500;
}

.cart-summary-breakdown .summary-total {
    font-size: 1.6em;
    font-weight: 700;
    color: #667eea;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 3px solid #667eea;
    text-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}


/* =================================
   5. Document View (Invoice, Order, etc.)
   ================================= */
.document-box {
    max-width: 850px;
    margin: auto;
    padding: 40px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    line-height: 1.7;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.document-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}
.document-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}
.logo-container {
    flex-shrink: 0;
    max-width: 280px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}
.document-logo {
    max-width: 100%;
    max-height: 120px;
    height: auto;
    border-radius: 8px;
}
.company-details {
    text-align: right;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}
.customer-details {
    padding-top: 25px;
    background: rgba(102, 126, 234, 0.03);
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}
.document-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 25px;
    text-align: right;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.document-items-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.document-items-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

.document-items-table tfoot td {
    font-weight: 700;
    border-top: 3px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    font-size: 1.1em;
}
.document-actions {
    margin-top: 40px;
    text-align: center;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* =================================
   6. Alerts & Status Badges
   ================================= */
.alert {
    padding: 18px 24px;
    border: none;
    border-radius: 12px;
    margin-bottom: 25px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
}

.alert.success {
    color: #155724;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 4px solid #28a745;
}

.alert.success::before {
    background: #28a745;
}

.alert.error {
    color: #721c24;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left: 4px solid #dc3545;
}

.alert.error::before {
    background: #dc3545;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.status-badge:hover {
    transform: translateY(-1px);
}

.status-paid, .status-completed {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.status-unpaid, .status-cancelled {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.status-overdue, .status-pending, .status-draft, .status-ordered {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: #ffffff;
}

.status-processing {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}


/* =================================
   7. Print Styles
   ================================= */
@media print {
    .sidebar,
    .main-content > h1,
    .main-content > .alert,
    .main-content > a,
    .document-actions,
    .quick-actions,
    .styled-form {
        display: none;
    }

    body, .app-container {
        background-color: #ffffff;
        padding: 0;
        margin: 0;
    }

    .main-content {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .document-box {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* =================================
   8. Modern Enhancements & Animations
   ================================= */

/* Loading Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.main-content > * {
    animation: fadeInUp 0.6s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Improved Typography */
h1, h2, h3, h4, h5, h6 {
    color: #2d3748;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

h1 {
    font-size: 2.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
}

h2 {
    font-size: 2em;
    color: #4a5568;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        order: 2;
    }
    
    .main-content {
        margin: 10px;
        padding: 20px;
        order: 1;
    }
    
    .dashboard-stats {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .pos-container {
        flex-direction: column;
    }
    
    .product-selection, .sale-cart {
        width: 100%;
    }
    
    h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .main-content {
        margin: 5px;
        padding: 15px;
    }
    
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .document-actions {
        flex-direction: column;
    }
}