/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazir', 'Tahoma', sans-serif;
    direction: rtl;
    text-align: right;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #1a202c;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #4F46E5;
    margin: 0;
}

.app-title svg {
    width: 32px;
    height: 32px;
}

.settings-btn {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #718096;
}

.settings-btn:hover {
    background: #edf2f7;
    color: #4F46E5;
    transform: translateY(-1px);
}

/* Main Content */
.main {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Invoice Type Selector */
.invoice-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.radio-card {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 0.875rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    position: relative;
}

.radio-card:hover {
    border-color: #4F46E5;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-card input[type="radio"]:checked + .radio-content {
    color: #4F46E5;
}

.radio-card input[type="radio"]:checked {
    & ~ .radio-content::before {
        background: #4F46E5;
        border-color: #4F46E5;
    }
    
    & ~ .radio-content::after {
        opacity: 1;
    }
}

.radio-card:has(input:checked) {
    background: #f0f4ff;
    border-color: #4F46E5;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.radio-content {
    display: block;
    position: relative;
    padding-right: 2.5rem;
}

.radio-content::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    background: white;
    transition: all 0.2s;
}

.radio-content::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    opacity: 0;
    transition: all 0.2s;
}

.radio-title {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.radio-desc {
    display: block;
    font-size: 0.875rem;
    color: #718096;
}

/* Sections */
.section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 1.25rem;
    background: #4F46E5;
    border-radius: 2px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
    color: #2d3748;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* Invoice Items */
.invoice-items {
    margin-bottom: 1.5rem;
}

.invoice-item {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    transition: all 0.2s;
}

.invoice-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.item-number {
    background: #4F46E5;
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.remove-item-btn {
    background: #fed7d7;
    color: #e53e3e;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-item-btn:hover {
    background: #feb2b2;
    transform: scale(1.05);
}

.item-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-btn {
    background: #4F46E5;
    color: white;
    border: none;
    border-radius: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
    font-weight: 600;
}

.quantity-btn:hover {
    background: #4338ca;
    transform: scale(1.05);
}

.quantity-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

.quantity-display {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    width: 3rem;
    text-align: center;
    padding: 0.5rem;
    font-weight: 600;
    color: #2d3748;
}

.add-item-btn {
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    color: white;
    border: none;
    border-radius: 0.875rem;
    padding: 1rem 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.add-item-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

/* Total Section */
.total-section {
    background: linear-gradient(135deg, #2d3748, #4a5568);
    color: white;
    border-radius: 1rem;
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.total-label {
    font-size: 1.25rem;
    font-weight: 600;
}

.total-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #68d391;
}

.total-words {
    font-size: 1rem;
    opacity: 0.9;
    font-style: italic;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.action-btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 0.875rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.action-btn.primary {
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.action-btn.secondary {
    background: white;
    color: #4F46E5;
    border: 2px solid #4F46E5;
}

.action-btn.secondary:hover {
    background: #4F46E5;
    color: white;
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #718096;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #e2e8f0;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #4F46E5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 1.125rem;
    color: #4a5568;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header-content {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .app-title svg {
        width: 28px;
        height: 28px;
    }
    
    .main {
        padding: 1.5rem;
    }
    
    .invoice-type-selector {
        grid-template-columns: 1fr;
    }
    
    .item-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .total-row {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .main {
        padding: 1rem;
    }
    
    .section-title {
        font-size: 1.125rem;
    }
    
    .invoice-item {
        padding: 1rem;
    }
    
    .total-section {
        padding: 1.5rem;
    }
    
    .total-amount {
        font-size: 1.75rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
    }
    
    .header,
    .action-buttons,
    .add-item-btn,
    .settings-btn,
    .remove-item-btn {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .main {
        box-shadow: none;
        border: none;
        padding: 1rem;
    }
}

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

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

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

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Selection */
::selection {
    background: rgba(79, 70, 229, 0.2);
    color: #1a202c;
}

::-moz-selection {
    background: rgba(79, 70, 229, 0.2);
    color: #1a202c;
}