/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
    color: #1f2937;
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background: var(--gradient-primary);
    color: #fff;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-menu a {
    color: #fff;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 5px;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: rgba(255,255,255,0.2);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 30px 0;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 20px;
    padding: 24px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.page-header h1 {
    color: var(--dark-color);
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.page-header h1 i {
    color: var(--primary-color);
}

/* Cards */
.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.card-header h2 {
    color: var(--dark-color);
    font-size: 1.4rem;
    font-weight: 600;
}

.card-header h2 {
    color: #333;
    font-size: 1.3rem;
}

.card-body {
    padding: 24px;
    background: #fff;
}

.card-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: #fff;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: var(--gradient-danger);
    color: #fff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: #333;
}

.btn-outline:hover {
    background: #f8f9fa;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 14px;
}

.form-group .required {
    color: var(--danger-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-form {
    margin-bottom: 20px;
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #6c757d;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
}

.table thead {
    background: var(--gradient-primary);
    color: #fff;
}

.table th {
    padding: 16px;
    text-align: right;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    transform: scale(1.01);
    box-shadow: var(--shadow-sm);
}

.action-buttons {
    display: flex;
    gap: 5px;
}

.btn-icon {
    padding: 5px 10px;
    border-radius: 3px;
    text-decoration: none;
    color: #667eea;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: #f0f0f0;
}

.btn-icon.btn-danger {
    color: #dc3545;
}

.btn-icon.btn-danger:hover {
    background: #ffe0e0;
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-draft {
    background: #e2e3e5;
    color: #383d41;
}

.badge-sent {
    background: #cfe2ff;
    color: #084298;
}

.badge-accepted {
    background: #d1e7dd;
    color: #0f5132;
}

.badge-rejected {
    background: #f8d7da;
    color: #842029;
}

.badge-expired {
    background: #fff3cd;
    color: #856404;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 2px solid #10b981;
}

.alert-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #ef4444;
}

.alert i {
    font-size: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.orange {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.green {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.purple {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-icon.red {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 2.25rem;
    color: var(--dark-color);
    margin-bottom: 4px;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

/* Devis Container */
.devis-container {
    background: #fff;
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.devis-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #667eea;
}

.devis-logo img {
    max-width: 150px;
    max-height: 100px;
}

.devis-company-info h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.devis-title {
    text-align: center;
    margin: 30px 0;
}

.devis-title h1 {
    font-size: 36px;
    color: #667eea;
    font-weight: bold;
}

.devis-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
}

.devis-info-left,
.devis-info-right {
    flex: 1;
}

.devis-info-right {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
}

.devis-info-right h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.devis-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.devis-table thead {
    background: #667eea;
    color: #fff;
}

.devis-table th,
.devis-table td {
    padding: 12px;
    text-align: right;
    border: 1px solid #ddd;
}

.devis-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.devis-totals {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.totals-table {
    width: 300px;
    border-collapse: collapse;
}

.totals-table td {
    padding: 8px;
    border: 1px solid #ddd;
}

.totals-table .total-final {
    background: #667eea;
    color: #fff;
    font-size: 18px;
}

.devis-notes {
    margin-top: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
}

.devis-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 12px;
}

.devis-legal-info {
    margin-top: 10px;
}

.devis-legal-info span {
    margin: 0 10px;
}

.totals-section {
    margin-top: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 16px;
    color: var(--dark-color);
}

.total-row.total-final {
    border-bottom: none;
    font-size: 20px;
    font-weight: 700;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 3px solid var(--primary-color);
    color: var(--primary-color);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gradient-primary);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: moveBackground 20s linear infinite;
}

@keyframes moveBackground {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-box {
    background: #fff;
    padding: 48px;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header i {
    color: var(--primary-color);
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 6px rgba(102, 126, 234, 0.3));
}

.login-header h1 {
    color: var(--dark-color);
    margin-bottom: 8px;
    font-size: 2rem;
    font-weight: 700;
}

.login-header p {
    color: #6b7280;
    font-size: 14px;
}

.login-form {
    margin-top: 30px;
}

.login-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 12px;
    color: #6c757d;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #fff;
    text-align: center;
    padding: 24px 0;
    margin-top: 60px;
    box-shadow: 0 -4px 6px rgba(0,0,0,0.1);
}

/* Utility Classes */
.text-muted {
    color: #6b7280;
}

.logo-preview {
    margin-bottom: 10px;
}

.logo-preview img {
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
}

.content-grid {
    display: grid;
    gap: 24px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-icon {
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(102, 126, 234, 0.1);
}

.btn-icon:hover {
    background: var(--primary-color);
    color: #fff;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-icon.btn-danger {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.btn-icon.btn-danger:hover {
    background: var(--danger-color);
    color: #fff;
}

.filter-form {
    background: #f9fafb;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Selection Color */
::selection {
    background: var(--primary-color);
    color: #fff;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        flex-direction: column;
        width: 100%;
        margin-top: 15px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .devis-info {
        flex-direction: column;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-info h3 {
        font-size: 1.75rem;
    }
}
