/* Persian Font and RTL Support */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    direction: rtl;
}

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background-color: #34495e;
}

/* Special navigation link styles */
.nav-link-special {
    background: linear-gradient(135deg, #27ae60, #2ecc71) !important;
    color: white !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    margin: 0 0.25rem !important;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.3) !important;
    transition: all 0.3s ease !important;
}

.nav-link-special:hover {
    background: linear-gradient(135deg, #229954, #27ae60) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.4) !important;
}

.nav-link-logout {
    color: #e74c3c !important;
    padding: 0.5rem !important;
    border-radius: 6px !important;
    transition: all 0.3s ease !important;
}

.nav-link-logout:hover {
    background-color: #e74c3c !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 3px 0;
    transition: 0.3s;
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        flex-direction: column;
        background-color: #2c3e50;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0,0,0,0.05);
        padding: 0;
        justify-content: space-between;
        z-index: 999;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu-header {
        position: absolute;
        top: 30px;
        right: 30px;
        z-index: 1000;
    }
    
    .nav-close-btn {
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.75rem;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }
    
    .nav-close-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
        transform: scale(1.1);
    }
    
    .nav-menu-content {
        padding: 100px 0 20px 0;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .nav-menu-footer {
        padding: 20px 0;
        width: 80%;
    }
    
    .nav-link {
        margin: 0.25rem 0;
        padding: 0.75rem 1rem;
        width: 100%;
        border-radius: 0;
    }
    
    /* Position logout button at bottom */
    .nav-link-logout {
        margin: 0;
        padding: 1rem;
        background-color: rgba(231, 76, 60, 0.1);
        border-radius: 0;
        font-weight: 600;
        width: 100%;
        display: block;
        text-align: center;
    }
}

/* Desktop overrides */
@media (min-width: 769px) {
    .nav-close-btn {
        display: none;
    }
    /* Ensure hamburger never shows on desktop */
    .hamburger {
        display: none !important;
    }
    /* Reset any mobile/off-canvas styles */
    .nav-menu {
        position: static;
        left: auto;
        top: auto;
        height: auto;
        flex-direction: row;
        background-color: transparent;
        width: auto;
        text-align: right;
        box-shadow: none;
        padding: 0;
        justify-content: flex-end;
        z-index: auto;
    }
    .nav-menu-header,
    .nav-menu-footer {
        position: static;
        padding: 0;
        border: none;
        background: none;
    }
    .nav-menu-content {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 2rem;
        padding: 0;
        flex: 0 1 auto;
    }
    .nav-link {
        width: auto;
        border-radius: 4px;
        margin: 0;
    }
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 80px;
    right: 1rem;
    z-index: 1001;
    max-width: 400px;
}

/* Splash (first-visit) */
.splash-overlay {
    position: fixed;
    inset: 0;
    background: #ffffff;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.splash-content {
    text-align: center;
}

.splash-logo {
    width: 160px;
    height: auto;
    border-radius: 12px;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.splash-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    margin: 1rem auto 0 auto;
    animation: spin 1s linear infinite;
}

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

.flash-message {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.flash-success {
    border-left: 4px solid #27ae60;
}

.flash-error {
    border-left: 4px solid #e74c3c;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #999;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

/* Cards */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

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

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

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    transition: border-color 0.3s;
    background-color: white;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

select.form-input {
    cursor: pointer;
}

select.form-input option {
    padding: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    transition: background-color 0.3s;
    text-align: center;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Expense Rows */
.expense-row {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding-top: 1rem;
    margin-bottom: 1rem;
}

.expense-row-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr auto;
    gap: 1rem;
    align-items: end;
}

.expense-row .form-group {
    margin-bottom: 0;
}

.btn-small {
    padding: 0.5rem;
    font-size: 0.8rem;
    min-width: auto;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-content form {
    padding: 1rem;
}

/* Event Cards */
.event-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.event-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}


.event-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #888;
}

/* Modern Event Cards */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.event-card-modern {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    padding: 0;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.event-card-modern:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #3498db;
}

.event-header {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.event-title-section {
    flex: 1;
}

.event-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}


.event-status {
    flex-shrink: 0;
}

.event-meta-modern {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.meta-item i {
    color: #3498db;
    width: 16px;
}

.participants-section,
.admins-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f3f4;
}

.participants-section:last-of-type,
.admins-section:last-of-type {
    border-bottom: none;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

.section-label i {
    color: #6c757d;
}

.participants-tags,
.admins-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.participant-tag-home {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.admin-tag-home {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.event-actions {
    padding: 1.5rem;
    background-color: #f8f9fa;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-full:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

/* Status Badges */
.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.status-closed {
    background-color: #6c757d;
    color: white;
}

.status-ready {
    background-color: #28a745;
    color: white;
}

.status-pending {
    background-color: #ffc107;
    color: #212529;
}

/* Closed Events Styles */
.closed-event {
    opacity: 0.9;
    border-color: #6c757d;
}

.closed-event:hover {
    border-color: #6c757d;
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.2);
}

.summary-stats {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.btn-outline-primary {
    background-color: transparent;
    border: 2px solid #3498db;
    color: #3498db;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    background-color: #3498db;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .events-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .event-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .event-meta-modern {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .participants-tags,
    .admins-tags {
        gap: 0.4rem;
    }
    
    .participant-tag-home,
    .admin-tag-home {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }
    
    .summary-stats {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .stat-item {
        padding: 0.5rem;
        background-color: rgba(255, 255, 255, 0.7);
        border-radius: 8px;
    }
}

/* Expense List */
.expense-item {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expense-info {
    flex: 1;
}

.expense-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.expense-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: #27ae60;
}

.expense-payer {
    font-size: 0.9rem;
    color: #666;
}

/* Participant List */
.participant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.participant-tag {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.participant-tag.confirmed {
    background-color: #27ae60;
}

.participant-tag.pending {
    background-color: #f39c12;
}

/* Checkbox Styling */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #3498db;
}

/* Tag Styling */
.tag {
    background-color: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    margin-left: 0.25rem;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-remove:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tag-container {
    min-height: 2rem;
}

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

.footer-content p {
    margin: 0;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem 0;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .expense-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .event-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Auth pages (login/register) mobile layout: avoid scroll */
@media (max-width: 768px) {
    body.auth-page .main-content { padding: 0.5rem 0; }
    body.auth-page .container { padding: 0 0.75rem; }
    body.auth-page .card { margin: 0.5rem auto !important; }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 1rem;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Event Summary Styles */
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding: 1rem 0;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1rem;
}

.summary-amount {
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.85rem;
}

.status-badge.status-ready {
    background-color: #27ae60;
    color: white;
}

.status-badge.status-pending {
    background-color: #e74c3c;
    color: white;
}

.status-badge.status-closed {
    background-color: #6c757d;
    color: white;
}

/* Event Header Layout */
.event-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.event-title-section {
    flex: 1;
}

.event-date-section {
    text-align: left;
    min-width: 120px;
}

.event-date {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 0;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Admin Tag Styles */
.participant-tag.admin-tag {
    background-color: #f39c12;
    color: white;
    border: 2px solid #e67e22;
    font-weight: bold;
}

.participant-tag.admin-tag i {
    color: #fff;
}

/* Payment Settlement Minimal Styles */
.payment-settlement-minimal {
    padding: 0.5rem 0;
}

.payment-list-minimal {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.payment-item-minimal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #27ae60;
    transition: all 0.3s ease;
}

.payment-item-minimal.paid {
    background-color: #d4edda;
    border-left-color: #28a745;
    opacity: 0.7;
}

.payment-text {
    font-size: 0.95rem;
    color: #2c3e50;
    flex: 1;
}

.payment-amount-minimal {
    font-size: 1rem;
    font-weight: bold;
    color: #27ae60;
    margin: 0 1rem;
}

.copy-card-minimal {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.copy-card-minimal:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.payment-actions-minimal {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-number {
    font-family: monospace;
    font-size: 0.85rem;
    color: #6c757d;
    background-color: #e9ecef;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.mark-paid-btn {
    background: none;
    border: 1px solid #28a745;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: #28a745;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.mark-paid-btn:hover {
    background-color: #28a745;
    color: white;
}

.mark-paid-btn.paid {
    background-color: #28a745;
    color: white;
    cursor: default;
}

.payment-status-text {
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
    padding: 0.25rem 0.5rem;
}

.payment-status-text.closed {
    color: #28a745;
    font-weight: bold;
    font-style: normal;
}

.no-payments-minimal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #27ae60;
    font-size: 0.9rem;
}

.no-payments-minimal i {
    font-size: 1.2rem;
}

.event-closed {
    color: #6c757d;
    padding: 2rem;
}

.event-closed i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dc3545;
}

.event-closed h3 {
    color: #dc3545;
    margin-bottom: 0.5rem;
}

.event-closed p {
    margin: 0;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .summary-row {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .event-header-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .event-date-section {
        text-align: center;
    }
    
    .payment-item {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .payment-actions {
        margin-left: 0;
    }
}

/* Pagination Styles */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination .page-item {
    margin: 0 2px;
}

.pagination .page-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #007bff;
    text-decoration: none;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.pagination .page-link:hover {
    color: #0056b3;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination .page-item.active .page-link {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    background-color: #fff;
    border-color: #dee2e6;
    cursor: not-allowed;
}

.pagination .page-item.disabled .page-link:hover {
    color: #6c757d;
    background-color: #fff;
    border-color: #dee2e6;
}

@media (max-width: 768px) {
    /* Hide total amount column/content on mobile */
    .hide-total-mobile { display: none !important; }

    /* Adjust grid templates when total column is hidden */
    .add-form-header { grid-template-columns: 2fr 1fr 1fr 1fr 64px !important; }
    .expenses-list-header,
    .expenses-list-row { grid-template-columns: 2fr 1fr 1fr 1fr 1fr !important; }

    /* Fallback for any expense grid without classes: hide 5th column */
    .expense-row > :nth-child(5) { display: none !important; }
}

/* Tablet alignment for expenses list (ensure header and rows match) */
@media (max-width: 1024px) {
    /* Hide total column on tablet for consistency */
    .hide-total-mobile { display: none !important; }

    /* Match grid templates between header and rows */
    .add-form-header { grid-template-columns: 2fr 1fr 1fr 1fr 64px !important; }
    .expenses-list-header,
    .expenses-list-row { grid-template-columns: 2fr 1fr 1fr 1fr 1fr !important; }

    /* Fallback: hide 5th column in all expense rows */
    .expense-row > :nth-child(5) { display: none !important; }

    /* Dynamic add-expense rows on tablet */
    #expense-rows .expense-row { grid-template-columns: 2fr 1fr 1fr 1fr 64px !important; }

    /* Slightly smaller fonts in add-expense area */
    .add-form-header > div,
    #expense-rows .expense-row > * { font-size: 0.95rem; }
}

@media (max-width: 768px) {
    /* Dynamic add-expense rows: adjust after hiding total */
    #expense-rows .expense-row { grid-template-columns: 2fr 1fr 1fr 1fr 64px !important; }

    /* Expenses list rows identified by data attribute */
    .expense-row[data-expense-id] { grid-template-columns: 2fr 1fr 1fr 1fr 1fr !important; }
}

@media (max-width: 768px) {
    /* Smaller admin edit/delete buttons inside the first cell of each expense row */
    .expenses-list-row > div:first-child button { 
        width: 28px !important; 
        height: 28px !important; 
        font-size: 0.8rem !important; 
        padding: 0.25rem !important;
    }

    /* Also cover inline edit form action buttons on mobile */
    .expense-edit-form button {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.8rem !important;
        padding: 0.25rem !important;
    }

    /* Slightly smaller text in expense rows and header on mobile */
    .expenses-list-row { font-size: 0.95rem; }
    .expenses-list-header { font-size: 0.95rem; }

    /* Ensure title cell doesn’t dominate */
    .expenses-list-row > div:first-child { font-size: 0.95rem; }
}

@media (max-width: 768px) {
    /* Quick settlement first box: show in three lines */
    .payment-settlement-box .payment-item-minimal {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-areas:
            "text"
            "actions"
            "amount" !important;
        gap: 0.5rem !important;
        text-align: right !important;
    }
    .payment-settlement-box .payment-item-minimal .payment-text {
        grid-area: text !important;
        margin: 0 !important;
    }
    .payment-settlement-box .payment-item-minimal .payment-actions-minimal {
        grid-area: actions !important;
        justify-content: flex-start !important;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    .payment-settlement-box .payment-item-minimal .card-number {
        margin-inline-start: 0 !important;
    }
    .payment-settlement-box .payment-item-minimal .payment-amount-minimal {
        grid-area: amount !important;
        margin: 0 !important;
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        color: #27ae60 !important;
    }
}

@media (max-width: 768px) {
    /* Center all three lines on mobile */
    .payment-settlement-box .payment-item-minimal { 
        text-align: center !important; 
        align-items: center !important;
    }
    .payment-settlement-box .payment-item-minimal .payment-text { 
        text-align: center !important; 
        width: 100%;
    }
    .payment-settlement-box .payment-item-minimal .payment-actions-minimal { 
        justify-content: center !important; 
        width: 100%;
    }
    .payment-settlement-box .payment-item-minimal .payment-amount-minimal { 
        text-align: center !important; 
        width: 100%;
    }
}

@media (max-width: 768px) {
    /* Reduce padding in quick settlement area on mobile */
    .payment-settlement-box { padding: 0.5rem !important; }
    .payment-settlement-box .card-body { padding: 0.75rem !important; }
    .payment-settlement-box .payment-item-minimal { padding: 0.5rem 0.75rem !important; }
    .payment-settlement-box .payment-list-minimal { gap: 0.4rem !important; }
}

@media (max-width: 768px) {
    /* Increase spacing between the three lines */
    .payment-settlement-box .payment-item-minimal { gap: 0.75rem !important; }

    /* Remove the left border line on quick settlement items */
    .payment-settlement-box .payment-item-minimal { border-left: 0 !important; }

    /* Hide the green bracket bar in the first quick settlement box */
    .payment-settlement-box .card-body > div:first-child > div:first-child { display: none !important; }
}

@media (max-width: 768px) {
    /* Overall payments list: three-line layout on mobile (keep left border) */
    .payment-settlement-minimal .payment-item-minimal {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-areas:
            "text"
            "actions"
            "amount" !important;
        gap: 0.75rem !important;
        text-align: center !important;
        align-items: center !important;
        padding: 0.5rem 0.75rem !important;
        /* keep border-left as is */
    }
    .payment-settlement-minimal .payment-item-minimal .payment-text {
        grid-area: text !important;
        width: 100%;
    }
    .payment-settlement-minimal .payment-item-minimal .payment-actions-minimal {
        grid-area: actions !important;
        justify-content: center !important;
        width: 100%;
        gap: 0.5rem !important;
        flex-wrap: wrap;
    }
    .payment-settlement-minimal .payment-item-minimal .payment-amount-minimal {
        grid-area: amount !important;
        width: 100%;
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        color: #27ae60 !important;
        margin: 0 !important;
        text-align: center !important;
    }
}

@media (max-width: 768px) {
    /* Reduce left/right padding for share detail items under quick settlement */
    .payment-settlement-box .card-body div[style*='border-right: 3px solid #28a745'] {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }
}

/* Add-expense mobile redesign */
@media (max-width: 768px) {
    /* Header: keep only the add button, make it full-width */
    .add-form-header { grid-template-columns: 1fr !important; }
    .add-form-header > div:not(:last-child) { display: none !important; }
    .add-form-header > div:last-child button { width: 100% !important; height: 44px !important; font-size: 1rem !important; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
    /* Add a clear label to the add button on mobile */
    .add-form-header > div:last-child button::after { content: "افزودن ردیف هزینه"; }

    /* Rows: stack fields for usability */
    #expense-rows { padding: 0.5rem !important; }
    #expense-rows .expense-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-areas:
            "title title"
            "payer payer"
            "qty unit"
            "total actions" !important;
        gap: 0.5rem !important;
        align-items: stretch !important;
        padding: 0.5rem !important;
    }
    #expense-rows .expense-row > :nth-child(1) { grid-area: title !important; }
    #expense-rows .expense-row > :nth-child(2) { grid-area: payer !important; }
    #expense-rows .expense-row > :nth-child(3) { grid-area: qty !important; }
    #expense-rows .expense-row > :nth-child(4) { grid-area: unit !important; }
    #expense-rows .expense-row > :nth-child(5) { grid-area: total !important; }
    #expense-rows .expense-row > :nth-child(6) { grid-area: actions !important; }

    /* Re-show total column for add-expense rows on mobile */
    #expense-rows .expense-row > :nth-child(5) { display: block !important; }

    /* Larger touch targets */
    #expense-rows .expense-row input.form-input,
    #expense-rows .expense-row select.form-input { padding: 0.65rem 0.75rem !important; font-size: 1rem !important; }
    #expense-rows .expense-row .total-amount-display { padding: 0.65rem !important; }
    #expense-rows .expense-row button { height: 44px !important; }

    /* Submit button full-width */
    #bulk-expense-footer .btn { width: 100% !important; }
}

/* Expense edit form mobile redesign */
@media (max-width: 768px) {
    .expense-edit-form {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-areas:
            "title title"
            "payer payer"
            "qty unit"
            "total actions" !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
        align-items: stretch !important;
    }
    .expense-edit-form > :nth-child(1) { grid-area: title !important; }
    .expense-edit-form > :nth-child(2) { grid-area: payer !important; }
    .expense-edit-form > :nth-child(3) { grid-area: qty !important; }
    .expense-edit-form > :nth-child(4) { grid-area: unit !important; }
    .expense-edit-form > :nth-child(5) { grid-area: total !important; }
    .expense-edit-form > :nth-child(6) { grid-area: actions !important; }

    .expense-edit-form input.form-input,
    .expense-edit-form select.form-input { padding: 0.65rem 0.75rem !important; font-size: 1rem !important; }
    .expense-edit-form #edit-total-display { padding: 0.65rem !important; }
    .expense-edit-form button { height: 44px !important; }
    .expense-edit-form > div:last-child { display: flex; gap: 0.5rem; justify-content: center; }
}

/* Mobile font sizing for expenses list */
@media (max-width: 768px) {
    /* Header row and data rows: make text smaller */
    .add-form-header > div,
    .expense-row[data-expense-id] > div,
    .expense-row:not([data-expense-id]) > div {
        font-size: 0.9rem;
    }

    /* Specifically: نام هزینه، پرداخت‌کننده، مبلغ واحد، تعداد، افزودن سهم */
    .expense-row > div:nth-child(1),
    .expense-row > div:nth-child(2),
    .expense-row > div:nth-child(3),
    .expense-row > div:nth-child(4),
    .expense-row > div:nth-child(6) {
        font-size: 0.9rem;
    }

    /* Override any inline larger font sizes inside cells */
    .expense-row [style*="font-size:"] {
        font-size: 0.95rem !important;
    }

    /* Slightly smaller buttons inside expense rows */
    .expense-row button {
        font-size: 0.8rem !important;
        padding: 0.25rem 0.5rem !important;
    }
}
