/* استيراد خط Cairo */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');

/* إعدادات عامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --light-bg: #f8fafc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* الروابط */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* الحاوية الرئيسية */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* شريط التنقل */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.navbar-nav {
    display: flex;
    gap: 10px;
    list-style: none;
    flex-wrap: wrap;
}

.navbar-nav a {
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s;
}

.navbar-nav a:hover,
.navbar-nav a.active {
    background: var(--primary-color);
    color: var(--white);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-user span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.navbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.navbar-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.navbar-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

@media (min-width: 769px) {
    .navbar-header {
        width: auto;
    }
}

/* المحتوى الرئيسي */
.main-content {
    padding: 30px 0;
    min-height: calc(100vh - 70px);
}

/* البطاقات */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* إحصائيات لوحة التحكم */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.stat-card.total .stat-value { color: var(--primary-color); }
.stat-card.pending .stat-value { color: var(--secondary-color); }
.stat-card.ready .stat-value { color: var(--warning-color); }
.stat-card.not-voted .stat-value { color: var(--danger-color); }

/* الجداول */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--light-bg);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* حالات الناخبين */
.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-pending {
    background: #f1f5f9;
    color: var(--secondary-color);
}

.status-ready {
    background: #fef3c7;
    color: #b45309;
}

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

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

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

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

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    color: var(--white);
}

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

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    color: var(--white);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    color: var(--white);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--light-bg);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* النماذج */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
}

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

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

/* البحث والفلترة */
.search-filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.search-filters .form-control {
    flex: 1;
    min-width: 200px;
}

.search-filters .btn {
    white-space: nowrap;
}

/* التنبيهات */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

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

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

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* صفحة تسجيل الدخول */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 180px;
    height: auto;
    display: inline-block;
}

/* نافذة التأكيد */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}

/* ترقيم الصفحات */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s;
}

.pagination a:hover {
    background: var(--light-bg);
}

.pagination .active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* شريط التقدم */
.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-bar .progress {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.3s;
}

/* إحصائيات المركز */
.station-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.station-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.station-card h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.station-card .stats-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.station-card .stats-row:last-child {
    border-bottom: none;
}

.station-card .stats-row span:first-child {
    color: var(--text-muted);
}

.station-card .stats-row span:last-child {
    font-weight: 600;
}

/* فارغ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text-color);
}

/* التحميل */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* التوافق مع الجوال */
@media (max-width: 992px) {
    .table th,
    .table td {
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    .btn-group {
        flex-wrap: wrap;
        gap: 5px;
    }

    .station-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 0;
    }

    .navbar .container {
        flex-direction: column;
        text-align: center;
    }

    .navbar-header {
        width: 100%;
        padding: 0 5px;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        padding-top: 15px;
        margin-top: 15px;
        border-top: 1px solid var(--border-color);
    }

    .navbar-menu.active {
        display: flex;
    }

    .navbar-nav {
        flex-direction: column;
        justify-content: center;
        width: 100%;
        gap: 5px;
    }

    .navbar-nav a {
        display: block;
        width: 100%;
        text-align: center;
    }

    .navbar-user {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid var(--border-color);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card .stat-value {
        font-size: 1.8rem;
    }

    .station-stats {
        grid-template-columns: 1fr;
    }

    /* Table responsive - horizontal scroll */
    .table-responsive {
        margin: 0 -20px;
        padding: 0 20px;
    }

    .table {
        min-width: 700px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .table td .btn-group {
        flex-direction: column;
        gap: 4px;
    }

    .table td .btn-group .btn {
        width: 100%;
        justify-content: center;
    }

    .card-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .card-header h1,
    .card-header h2 {
        font-size: 1.1rem;
    }

    .search-filters {
        flex-direction: column;
    }

    .search-filters .form-control {
        width: 100%;
        min-width: unset;
    }

    .search-filters .btn {
        width: 100%;
    }

    .btn-group {
        width: 100%;
        justify-content: center;
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    .modal {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Page title responsive */
    h1 {
        font-size: 1.5rem;
    }

    /* Pagination responsive */
    .pagination {
        gap: 3px;
    }

    .pagination a,
    .pagination span {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.9rem;
    }

    .container {
        padding: 0 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card {
        padding: 20px 15px;
    }

    .stat-card .stat-value {
        font-size: 2rem;
    }

    .login-card {
        padding: 25px 20px;
    }

    .login-card h1 {
        font-size: 1.4rem;
    }

    .login-logo img {
        max-width: 140px;
    }

    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 15px;
    }

    .card-header {
        padding: 15px;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .status-badge {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .navbar-brand {
        font-size: 1.2rem;
    }

    .navbar-nav a {
        padding: 6px 12px;
        font-size: 0.9rem;
    }

    .main-content {
        padding: 20px 0;
    }

    /* Hide less important columns on very small screens */
    .table .hide-mobile {
        display: none;
    }
}

/* طباعة */
@media print {
    .navbar,
    .btn,
    .search-filters,
    .pagination {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
    }
}

/* أيقونات بسيطة باستخدام CSS */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
}
