/* NF-Invoice System Styles - Optimized */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    direction: rtl;
    text-align: right;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    flex-shrink: 0;
}

/* Navigation Menu */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-menu a:hover,
.nav-menu a.active {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.mobile-menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 160px);
}

.page-title {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 2rem;
    color: #1e293b;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    font-weight: 600;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
}

.btn-success {
    background-color: #16a34a;
    color: white;
}

.btn-warning {
    background-color: #ea580c;
    color: white;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    min-width: 600px;
}

.table th,
.table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #374151;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-paid {
    background-color: #dcfce7;
    color: #166534;
}

.status-unpaid {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-partial {
    background-color: #fef3c7;
    color: #92400e;
}

/* Dashboard stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2563eb;
    word-break: break-word;
}

.stat-label {
    color: #6b7280;
    margin-top: 0.5rem;
}

/* Filters */
.filters {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 2rem;
    color: #1e293b;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fed7aa;
}

/* Footer */
.footer {
    background-color: #1e293b;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 1rem;
    }
    
    .form-row-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    /* Mobile Navigation */
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        border-radius: 0 0 1rem 1rem;
        gap: 0.5rem;
    }
    
    .nav-menu.mobile-open {
        display: flex;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-menu a {
        display: block;
        text-align: center;
        width: 100%;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .user-info {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .filters-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .table {
        font-size: 0.875rem;
        min-width: 700px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    .card-header,
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }
    
    .login-card {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .card-header,
    .card-body {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .table {
        font-size: 0.8rem;
        min-width: 650px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
    }
    
    .status-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
    
    .table-container {
        margin: 0 -0.75rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .form-control {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .form-label {
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .table {
        min-width: auto;
    }
}

/* RTL specific adjustments */
.table th:first-child,
.table td:first-child {
    text-align: left;
}

input[type="number"] {
    text-align: left;
}

.form-control[type="email"],
.form-control[type="url"] {
    direction: ltr;
    text-align: left;
}

/* Utility classes */
.mobile-hidden {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-hidden {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .mobile-stack {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
}

.table-wrapper {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: white;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

.card-header-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 768px) {
    .card-header-mobile {
        flex-direction: column;
        align-items: stretch;
    }
    
    .card-header-mobile > * {
        width: 100%;
        text-align: center;
    }
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.btn:focus,
.form-control:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}