/* ============================================
   CardsPage Component Styles
   ============================================ */

/* Container */
.cards-page-container {
    padding: 20px;
}

.cards-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.cards-page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.cards-page-actions {
    display: flex;
    gap: 8px;
}

/* Filters Row */
.cards-page-filters {
    background: #f8f9fa;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.cards-page-filters .row {
    margin: 0 -8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.cards-page-filters .form-group {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cards-page-filters .form-group label,
.cards-page-filters .form-group .control-label {
    margin-bottom: 0;
    white-space: nowrap;
    font-weight: 500;
    color: #555;
    min-width: auto;
}

.cards-page-filters .form-group .form-control,
.cards-page-filters .form-group select,
.cards-page-filters .form-group .k-dropdown,
.cards-page-filters .form-group .k-widget {
    min-width: 250px;
    flex: 1;
}

.cards-page-filters .col-md-3,
.cards-page-filters .col-md-4,
.cards-page-filters [class*="col-"] {
    padding: 0;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
}

/* Kendo dropdown specific fixes */
.cards-page-filters .k-dropdown-wrap {
    min-width: 250px;
}

.cards-page-filters .k-dropdown .k-input {
    padding: 8px 12px;
}

/* Sorting Controls */
.cards-page-sorting {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.cards-page-sorting label {
    margin: 0;
    font-weight: 500;
    color: #666;
    min-width: 65px;
}

.cards-page-sorting select {
    min-width: 180px;
}

/* Cards Grid */
.cards-page-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Responsive Grid */
@media (max-width: 1200px) {
    .cards-page-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .cards-page-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .cards-page-grid {
        grid-template-columns: 1fr;
    }
}

/* Base Card Styles */
.cards-page-card {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
    cursor: pointer;
}

.cards-page-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
    border-color: #d0d0d0;
}

.cards-page-card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.cards-page-card .card-body {
    padding: 20px;
}

.cards-page-card .card-footer {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

/* ============================================
   Sector Statistics Card Specific Styles
   ============================================ */

.sector-stat-card,
.town-stat-card {
    padding: 20px;
    text-align: right;
}

.sector-stat-card .location-indicator,
.town-stat-card .location-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.sector-stat-card .location-indicator i,
.town-stat-card .location-indicator i {
    font-size: 1.5rem;
    color: #4CAF50;
}

.sector-stat-card .sector-name,
.town-stat-card .town-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
}

/* Primary Statistic */
.sector-stat-card .stat-primary,
.town-stat-card .stat-primary {
    margin-bottom: 20px;
    text-align: center;
}

.sector-stat-card .stat-primary .stat-label,
.town-stat-card .stat-primary .stat-label {
    font-size: 1rem;
    color: #2196F3;
    margin-bottom: 8px;
    font-weight: 500;
}

.sector-stat-card .stat-primary .stat-value,
.town-stat-card .stat-primary .stat-value {
    font-size: 3rem;
    font-weight: 300;
    color: #2196F3;
    line-height: 1.2;
}

/* Badge Links */
.sector-stat-card .stat-badges,
.town-stat-card .stat-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sector-stat-card .stat-badges .badge,
.town-stat-card .stat-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    background: transparent;
}

.sector-stat-card .stat-badges .badge:hover,
.town-stat-card .stat-badges .badge:hover {
    transform: scale(1.05);
    text-decoration: none;
}

.sector-stat-card .stat-badges .badge-success,
.town-stat-card .stat-badges .badge-success {
    background: transparent;
    color: #4CAF50;
    border: 2px solid #4CAF50;
}

.sector-stat-card .stat-badges .badge-success:hover,
.town-stat-card .stat-badges .badge-success:hover {
    background: rgba(76, 175, 80, 0.1);
}

.sector-stat-card .stat-badges .badge-info,
.town-stat-card .stat-badges .badge-info {
    background: transparent;
    color: #2196F3;
    border: 2px solid #2196F3;
}

.sector-stat-card .stat-badges .badge-info:hover,
.town-stat-card .stat-badges .badge-info:hover {
    background: rgba(33, 150, 243, 0.1);
}

.sector-stat-card .stat-badges .badge i,
.town-stat-card .stat-badges .badge i {
    font-size: 1rem;
}

/* Icons Row (Ballot Boxes & Voting Centers) */
.town-stat-card .stat-icons-row {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 20px;
    color: #666;
}

.town-stat-card .stat-icon-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.town-stat-card .stat-icon-item i {
    font-size: 1.25rem;
    color: #888;
}

/* Secondary Statistic */
.sector-stat-card .stat-secondary,
.town-stat-card .stat-secondary {
    padding-top: 16px;
    border-top: 1px dashed #e0e0e0;
    text-align: center;
}

.sector-stat-card .stat-secondary .stat-label,
.town-stat-card .stat-secondary .stat-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 6px;
}

.sector-stat-card .stat-secondary .stat-value,
.town-stat-card .stat-secondary .stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2196F3;
}

/* ============================================
   Town Stats Card (New Template Classes)
   ============================================ */

.town-stats-card {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
}

.town-stats-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Header with location */
.town-stats-card .town-stats-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 20px 24px 16px;
}

.town-stats-card .town-stats-header i {
    font-size: 2.875rem;
    color: #4CAF50;
}

.town-stats-card .town-stats-header .town-name {
    font-size: 2.725rem;
    font-weight: 600;
    color: #333;
}

/* Body */
.town-stats-card .town-stats-body {
    padding: 0 24px 24px;
}

/* Primary Stat */
.town-stats-card .primary-stat {
    text-align: right;
    margin-bottom: 20px;
}

.town-stats-card .primary-label {
    font-size: 1.275rem;
    color: #2196F3;
    margin-bottom: 6px;
    font-weight: 400;
}

.town-stats-card .primary-value {
    font-size: 3.75rem;
    font-weight: 300;
    color: #2196F3;
    line-height: 1.1;
}

/* Badges Row */
.town-stats-card .badges-row {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.town-stats-card .stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 20px;
    font-size: 1.8rem;
    font-weight: 500;
    background: transparent;
    transition: all 0.2s ease;
}

.town-stats-card .stat-badge:hover {
    transform: scale(1.05);
}

.town-stats-card .badge-green {
    color: #4CAF50;
    border: 1.5px solid #4CAF50;
}

.town-stats-card .badge-green:hover {
    background: rgba(76, 175, 80, 0.1);
}

.town-stats-card .badge-blue {
    color: #2196F3;
    border: 1.5px solid #2196F3;
}

.town-stats-card .badge-blue:hover {
    background: rgba(33, 150, 243, 0.1);
}

.town-stats-card .stat-badge i {
    font-size: 1.275rem;
}

/* Icons Row */
.town-stats-card .icons-row {
    display: flex;
    justify-content: flex-start;
    gap: 32px;
    margin-bottom: 20px;
    color: #777;
}

.town-stats-card .icon-stat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 2.425rem;
}

.town-stats-card .icon-stat i {
    font-size: 2.5rem;
    color: #999;
}

/* Secondary Stat */
.town-stats-card .secondary-stat {
    padding-top: 18px;
    border-top: 1px dashed #e0e0e0;
    text-align: right;
}

.town-stats-card .secondary-label {
    font-size: 1.2rem;
    color: #888;
    margin-bottom: 6px;
}

.town-stats-card .secondary-value {
    font-size: 2.25rem;
    font-weight: 400;
    /* color: #2196F3; */
}

/* Footer */
.sector-stat-card .card-footer {
    font-size: 0.85rem;
}

/* ============================================
   Empty State
   ============================================ */

.cards-page-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.cards-page-empty i {
    font-size: 4rem;
    margin-bottom: 16px;
    color: #ccc;
}

.cards-page-empty .message {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.cards-page-empty .action-btn {
    margin-top: 12px;
}

/* ============================================
   Loading State
   ============================================ */

.cards-page-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.cards-page-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f0f0f0;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Pagination
   ============================================ */

.cards-page-pagination {
    display: flex;
    justify-content: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

/* ============================================
   RTL Support
   ============================================ */

[dir="rtl"] .cards-page-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .sector-stat-card,
[dir="rtl"] .town-stat-card {
    text-align: right;
}

[dir="rtl"] .sector-stat-card .location-indicator,
[dir="rtl"] .town-stat-card .location-indicator {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

[dir="rtl"] .sector-stat-card .stat-badges .badge,
[dir="rtl"] .town-stat-card .stat-badges .badge {
    flex-direction: row-reverse;
}

/* Town Stats Card RTL */
[dir="rtl"] .town-stats-card .town-stats-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .town-stats-card .stat-badge {
    flex-direction: row-reverse;
}

[dir="rtl"] .town-stats-card .icon-stat {
    flex-direction: row-reverse;
}

/* LTR - Left align for non-Arabic */
html:not([dir="rtl"]) .sector-stat-card,
html:not([dir="rtl"]) .town-stat-card {
    text-align: left;
}

html:not([dir="rtl"]) .sector-stat-card .location-indicator,
html:not([dir="rtl"]) .town-stat-card .location-indicator {
    justify-content: flex-start;
}

html:not([dir="rtl"]) .town-stats-card .town-stats-header {
    justify-content: flex-start;
}

/* ============================================
   Election Comparison Card
   ============================================ */

.election-comparison-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.election-comparison-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

.election-comparison-card .card-header {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    padding: 18px 20px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.election-comparison-card .card-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
}

.election-comparison-card .location-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.election-comparison-card .location-indicator i {
    font-size: 1.5rem;
    color: #666;
}

.election-comparison-card .kaza-name {
    font-size: 2.35rem;
    font-weight: 700;
    color: #333;
}

.election-comparison-card .location-sub {
    color: #666;
    font-size: 1.5rem;
    padding-right: 34px;
}

.election-comparison-card .mouhafaza-name {
    font-weight: 500;
}

.election-comparison-card .town-count {
    opacity: 0.9;
}

.election-comparison-card .card-body {
    padding: 20px;
}

/* Primary Stat - Total Registered Voters */
.election-comparison-card .stat-primary {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: 10px;
    margin-bottom: 16px;
}

.election-comparison-card .stat-primary .stat-label {
    font-size: 0.85rem;
    color: #1565c0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.election-comparison-card .stat-primary .stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: #1976d2;
    line-height: 1.2;
}

/* Stat Row - 2022 vs 2026 Comparison */
.election-comparison-card .stat-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.election-comparison-card .stat-item {
    flex: 1;
    text-align: center;
    padding: 14px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.election-comparison-card .stat-item:hover {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.election-comparison-card .stat-item .stat-label {
    font-size: 1.2rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.election-comparison-card .stat-item .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.election-comparison-card .stat-item .stat-value.text-info {
    color: #0288d1;
}

.election-comparison-card .stat-item .stat-value.text-success {
    color: #2e7d32;
}

/* Secondary Stat - Percentage */
.election-comparison-card .stat-secondary {
    text-align: center;
    padding: 14px;
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border-radius: 8px;
    margin-bottom: 16px;
}

.election-comparison-card .stat-secondary .stat-label {
    font-size: 0.8rem;
    color: #f57c00;
    font-weight: 600;
    margin-bottom: 4px;
}

.election-comparison-card .stat-secondary .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.election-comparison-card .stat-secondary .stat-value.text-warning {
    color: #ef6c00;
}

/* Badges */
.election-comparison-card .stat-badges {
    display: flex;
    justify-content: center;
}

.election-comparison-card .stat-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.election-comparison-card .stat-badges .badge-primary {
    background: linear-gradient(135deg, #e8eaf6 0%, #c5cae9 100%);
    color: #3949ab;
    border: none;
}

.election-comparison-card .stat-badges .badge-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(57, 73, 171, 0.2);
}

.election-comparison-card .stat-badges .badge i {
    font-size: 1.4rem;
}

.election-comparison-card .stat-badges .badge strong {
    font-weight: 700;
    font-size: 1.35rem;
}

/* RTL Support */
[dir="rtl"] .election-comparison-card .location-indicator {
    flex-direction: row-reverse;
}

[dir="rtl"] .election-comparison-card .location-sub {
    padding-right: 0;
    padding-left: 34px;
    text-align: right;
}

[dir="rtl"] .election-comparison-card .stat-badges .badge {
    flex-direction: row-reverse;
}

/* ============================================
   Color Variants
   ============================================ */

/* Blue Theme */
.cards-page-card.theme-blue .stat-primary .stat-value {
    color: #2196F3;
}

/* Green Theme */
.cards-page-card.theme-green .stat-primary .stat-value {
    color: #4CAF50;
}

/* Orange Theme */
.cards-page-card.theme-orange .stat-primary .stat-value {
    color: #FF9800;
}

/* Red Theme */
.cards-page-card.theme-red .stat-primary .stat-value {
    color: #F44336;
}

/* Purple Theme */
.cards-page-card.theme-purple .stat-primary .stat-value {
    color: #9C27B0;
}

/* ============================================
   Color Coding Status Classes
   ============================================ */

/* Green Status - Good/Success */
.town-stats-card.card-status-green {
    border-left: 4px solid #4CAF50;
}

.town-stats-card.card-status-green .town-stats-header i {
    color: #4CAF50;
}

/* Red Status - Warning/Alert */
.town-stats-card.card-status-red {
    border-left: 4px solid #F44336;
}

.town-stats-card.card-status-red .town-stats-header i {
    color: #F44336;
}

/* Orange Status - Caution */
.town-stats-card.card-status-orange {
    border-left: 4px solid #FF9800;
}

.town-stats-card.card-status-orange .town-stats-header i {
    color: #FF9800;
}

/* Blue Status - Info */
.town-stats-card.card-status-blue {
    border-left: 4px solid #2196F3;
}

.town-stats-card.card-status-blue .town-stats-header i {
    color: #2196F3;
}

/* Neutral Status - Default */
.town-stats-card.card-status-neutral {
    border-left: 4px solid #9E9E9E;
}

.town-stats-card.card-status-neutral .town-stats-header i {
    color: #9E9E9E;
}

/* RTL - Use border-right instead */
[dir="rtl"] .town-stats-card.card-status-green,
[dir="rtl"] .town-stats-card.card-status-red,
[dir="rtl"] .town-stats-card.card-status-orange,
[dir="rtl"] .town-stats-card.card-status-blue,
[dir="rtl"] .town-stats-card.card-status-neutral {
    border-left: none;
    border-right: 4px solid;
}

[dir="rtl"] .town-stats-card.card-status-green {
    border-right-color: #4CAF50;
}

[dir="rtl"] .town-stats-card.card-status-red {
    border-right-color: #F44336;
}

[dir="rtl"] .town-stats-card.card-status-orange {
    border-right-color: #FF9800;
}

[dir="rtl"] .town-stats-card.card-status-blue {
    border-right-color: #2196F3;
}

[dir="rtl"] .town-stats-card.card-status-neutral {
    border-right-color: #9E9E9E;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    /* Ensure colors print correctly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Page setup */
    @page {
        margin: 10mm;
        size: A4;
    }

    /* Hide non-essential elements */
    .cards-page-header,
    .cards-page-filters,
    .cards-page-sorting,
    .cards-page-actions,
    .cards-page-pagination {
        display: none !important;
    }

    /* Grid layout for print */
    .cards-page-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
    }

    /* Prevent cards from breaking across pages */
    .cards-page-card-wrapper,
    .cards-page-card,
    .town-stats-card,
    .sector-stat-card,
    .town-stat-card,
    .card-content {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        -webkit-column-break-inside: avoid !important;
    }

    /* Card print styling */
    .town-stats-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        margin-bottom: 10px !important;
    }

    /* Ensure proper sizing */
    .cards-page-card-wrapper {
        margin-bottom: 12px !important;
    }
}
