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

:root {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}

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

/* Hidden elements */
.hidden { display: none !important; }

/* Login View */
.login-view {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e3a8a, #0f172a);
}

.login-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
}

.login-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.logo-section h1 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.stat-card.paid { border-right: 5px solid var(--success); }
.stat-card.pending { border-right: 5px solid var(--danger); }
.stat-card.total { border-right: 5px solid var(--primary); }

.stat-title {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-icon {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    opacity: 0.1;
    font-size: 3rem;
}

/* Content Area */
.main-content {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-main);
    outline: none;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Table Design */
.table-wrapper {
    overflow-x: auto;
}

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

th {
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background: rgba(255,255,255,0.02);
}

/* Status Badges */
.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-paid { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-pending { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-partial { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-icon {
    padding: 8px;
    border-radius: 0.5rem;
    background: var(--bg-input);
    color: var(--text-main);
}

.btn-icon:hover { background: var(--primary); }

.whatsapp-btn {
    background: #25d366;
    color: white;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 10px;
}

.modal {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: 1rem;
    padding: 2rem;
    position: relative;
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-main);
    outline: none;
}

/* Responsive Fixes */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    .table-controls { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }
    
    table thead { display: none; }
    table tr { 
        display: block; 
        margin-bottom: 1rem; 
        background: var(--bg-input); 
        padding: 1rem; 
        border-radius: 0.5rem;
    }
    table td { 
        display: flex; 
        justify-content: space-between; 
        border-bottom: none;
        padding: 8px 0;
    }
    table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
    }
}
