/* Application Form Styling */
.application-form-container {
    position: relative;
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.ballot-form-wrapper {
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.form-header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 1.5rem;
}

.form-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.form-notice {
    background: #fef7f0;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.form-notice p {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.required-note {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Instructions Panel */
.instructions-panel {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.instructions-panel h4 {
    color: #0369a1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

.instructions-panel ul {
    margin: 0;
    padding-left: 1.25rem;
}

.instructions-panel li {
    color: #0c4a6e;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

/* Form Layout */
.ballot-registration-form {
    margin-top: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
    width: 100%;
    box-sizing: border-box;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Form Labels */
.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.security-text{
    text-align: center;
}

.form-label.required::after {
    content: ' *';
    color: #ef4444;
    font-weight: 700;
}

/* Form Inputs */
.form-input,
.form-select,
.form-textarea {
    padding: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(234, 85, 71, 0.1);
}

.form-input:disabled,
.form-select:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Plan detail field styling */
#planDetail {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--primary-color);
    font-weight: 500;
    font-style: italic;
}

#planDetail:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(234, 85, 71, 0.1);
}

/* Form Note */
.form-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-style: italic;
}

/* Validation Messages */
.validation-message {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    min-height: 1rem;
}

/* Section Divider */
.section-divider {
    margin: 2rem 0 1.5rem 0;
    padding: 1rem 0;
    border-top: 2px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.section-divider h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

/* Payment Table Container */
/* .payment-table-container - REMOVED */

.table-responsive {
    overflow: hidden;
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    box-sizing: border-box;
}

.payment-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.9rem;
    table-layout: fixed;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
}

.payment-table th {
    background: var(--primary-color);
    color: white;
    padding: 1rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: visible;
    line-height: 1.3;
    height: auto;
    min-height: 60px;
    vertical-align: middle;
}

.payment-table td {
    padding: 0.875rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
    overflow: visible;
    text-overflow: visible;
    vertical-align: middle;
    font-size: 0.9rem;
}

.payment-table tbody tr:hover {
    background: #fef7f0;
}

/* Mobile-specific styling - 767px and below */
@media (max-width: 767px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .ballot-form-wrapper {
        padding: 1.25rem;
    }
    
    .form-header h2 {
        font-size: 1.5rem;
    }
    
    /* Form elements mobile optimization */
    .form-group {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-bottom: 0.5rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .form-label {
        font-size: 0.85rem;
        white-space: normal;
        line-height: 1.4;
    }
    
    /* Mobile dropdown text handling */
    .form-select {
        line-height: 1.4;
        min-height: 3rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .form-select option {
        font-size: 0.85rem;
        line-height: 1.3;
        padding: 0.5rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Form actions mobile layout */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    /* Submit button comes first on mobile */
    .form-actions .btn-primary {
        order: 1;
    }
    
    /* Reset button comes second on mobile */
    .form-actions .btn-secondary {
        order: 2;
    }
    
    .btn {
        min-width: auto;
        width: 100%;
        justify-content: center;
    }
    
    /* Captcha mobile layout */
    .captcha-container {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    /* Payment plan section mobile styling */
    .payment-plan-section {
        margin: 1.5rem 0 2rem 0;
        padding: 1.25rem;
    }
    
    .payment-plan-section .payment-section-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .payment-plan-section .payment-section-header h3 {
        font-size: 1.1rem;
    }
    
    .table-responsive {
        overflow: hidden;
        width: 100%;
        border-radius: 8px;
    }
    
    /* Hide original table structure on mobile */
    .payment-table thead {
        display: none;
    }
    
    .payment-table tbody {
        display: block;
    }
    
    .payment-table tr {
        display: block;
        background: white;
        border: 1px solid #f1f5f9;
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    }
    
    .payment-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: left;
        font-size: 0.8rem;
        border: none;
        word-wrap: break-word;
        white-space: normal;
    }
    
    .payment-table td:last-child {
        border-bottom: none;
    }
    
    /* Add original labels before each value on mobile */
    .payment-table td:nth-child(1)::before {
        content: "Total Amount (Million)";
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        margin-right: 1rem;
        min-width: 140px;
        flex-shrink: 0;
        line-height: 1.3;
    }
    
    .payment-table td:nth-child(2)::before {
        content: "Amount after 5% Discount (Million)";
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        margin-right: 1rem;
        min-width: 140px;
        flex-shrink: 0;
        line-height: 1.3;
    }
    
    .payment-table td:nth-child(3)::before {
        content: "Down Payment (Million)";
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        margin-right: 1rem;
        min-width: 140px;
        flex-shrink: 0;
        line-height: 1.3;
    }
    
    .payment-table td:nth-child(4)::before {
        content: "Remaining Amount (Million)";
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        margin-right: 1rem;
        min-width: 140px;
        flex-shrink: 0;
        line-height: 1.3;
    }
    
    .payment-table td:nth-child(5)::before {
        content: "1.5Yr Instl Plan (6x Qtly Instls)";
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.7rem;
        margin-right: 1rem;
        min-width: 140px;
        flex-shrink: 0;
        line-height: 1.3;
    }
}

/* Small mobile - 480px and below */
@media (max-width: 480px) {
    .ballot-form-wrapper {
        padding: 1rem;
    }
    
    .form-header h2 {
        font-size: 1.3rem;
    }
    
    .instructions-panel {
        padding: 1rem;
    }
    
    /* Optimized form elements for small screens */
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    /* Better dropdown handling for small screens */
    .form-select {
        font-size: 0.8rem;
        line-height: 1.3;
        padding: 0.7rem;
        min-height: 2.8rem;
    }
    
    .form-select option {
        font-size: 0.75rem;
        line-height: 1.2;
        padding: 0.4rem;
    }
    
    /* Payment plan section for small mobile */
    .payment-plan-section {
        margin: 1rem 0 1.5rem 0;
        padding: 1rem;
    }
    
    .payment-plan-section .payment-section-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    .payment-plan-section .payment-section-header h3 {
        font-size: 1rem;
    }
    
    .payment-table tr {
        padding: 0.875rem;
        margin-bottom: 0.75rem;
    }
    
    .payment-table td {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.375rem 0;
        gap: 0.25rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--primary-color);
    }
    
    .payment-table td:nth-child(1)::before,
    .payment-table td:nth-child(2)::before,
    .payment-table td:nth-child(3)::before,
    .payment-table td:nth-child(4)::before,
    .payment-table td:nth-child(5)::before {
        min-width: auto;
        margin-right: 0;
        margin-bottom: 0.125rem;
        font-size: 0.65rem;
        line-height: 1.2;
    }
    
    /* Section divider adjustments */
    .section-divider {
        margin: 1.5rem 0 1rem 0;
        padding: 0.75rem 0;
    }
    
    .section-divider h3 {
        font-size: 1.1rem;
    }
    
    /* Payment section adjustments */
    .payment-section {
        padding: 1.25rem;
        margin-top: 1.5rem;
    }
    
    .payment-section-header h3 {
        font-size: 1.1rem;
    }
    
    /* Validation section adjustments */
    .validation-section {
        padding: 1rem;
    }
    
    .captcha-image {
        min-width: 100px;
        height: 45px;
        font-size: 1.2rem;
        padding: 0.5rem 0.75rem;
    }
    
    .refresh-captcha {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
}

/* Payment Plan Section - Same styling as Payment Section */
.payment-plan-section {
    background: #fefefe;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0 2.5rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.payment-plan-section .payment-section-header {
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 1rem;
}

.payment-plan-section .payment-section-header h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.payment-plan-section .table-responsive {
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
}

/* Payment Section */
.payment-section {
    background: #fefefe;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.payment-section-header {
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 1rem;
}

.payment-section-header h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.payment-options-row {
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.payment-options-row .form-group {
    grid-column: span 2;
}

.payment-options-row .form-select {
    width: 100%;
    padding: 0.875rem;
}

/* Bank Group */
#bankGroup {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    display: none !important;
}

#bankGroup.show {
    opacity: 1;
    transform: translateY(0);
    display: inline-block !important;
}

/* Validation Section */
.validation-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 1rem;
    text-align: center;
}

.validation-section .form-group {
    max-width: 400px;
    margin: 0 auto;
    text-align: left;
}

.validation-section .form-input {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

/* Captcha */
.captcha-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.captcha-image {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border: 2px solid #d1d5db;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 2px;
    text-align: center;
    min-width: 100px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    position: relative;
    overflow: hidden;
    text-decoration: line-through;
}

.captcha-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 48%, rgba(234, 85, 71, 0.1) 50%, transparent 52%);
    pointer-events: none;
}

.refresh-captcha {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-captcha:hover {
    background: #d63431;
    transform: rotate(180deg);
}

.captcha-refresh-link {
    margin-top: 0.5rem;
    text-align: center;
}

.captcha-refresh-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.captcha-refresh-link a:hover {
    text-decoration: underline;
    color: #d63431;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f5f9;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    font-family: inherit;
    min-width: 150px;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #d63431;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(234, 85, 71, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-secondary);
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #f9fafb;
    color: var(--text-primary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn i {
    font-size: 0.9rem;
}

/* Responsive Design - Better organized breakpoints */
@media (max-width: 1400px) {
    .form-row {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 1200px) {
    .form-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 1024px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .ballot-form-wrapper {
        padding: 1.5rem;
    }
    
    /* Better form element sizing */
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .form-label {
        font-size: 0.85rem;
        white-space: normal;
    }
    
    /* Payment table adjustments for tablet */
    .payment-table {
        font-size: 0.85rem;
    }
    
    .payment-table th {
        padding: 0.9rem 0.4rem;
        font-size: 0.75rem;
        min-height: 55px;
        line-height: 1.2;
    }
    
    .payment-table td {
        padding: 0.75rem 0.4rem;
        font-size: 0.8rem;
    }
}

/* Tablet portrait and small laptop screens */
@media (max-width: 900px) and (min-width: 769px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.1rem;
    }
    
    .ballot-form-wrapper {
        padding: 1.4rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.75rem;
        font-size: 0.88rem;
    }
    
    .form-label {
        font-size: 0.83rem;
    }
    
    /* Payment table for tablet */
    .payment-table {
        font-size: 0.8rem;
    }
    
    .payment-table th {
        padding: 0.8rem 0.3rem;
        font-size: 0.7rem;
        min-height: 50px;
        line-height: 1.1;
    }
    
    .payment-table td {
        padding: 0.7rem 0.3rem;
        font-size: 0.75rem;
    }
    
    /* Form actions for tablet */
    .form-actions {
        gap: 0.8rem;
    }
    
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 900px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .ballot-form-wrapper {
        padding: 1.5rem;
    }
    
    /* Payment table responsive adjustments */
    .payment-table {
        font-size: 0.8rem;
    }
    
    .payment-table th {
        padding: 0.75rem 0.3rem;
        font-size: 0.7rem;
        min-height: 45px;
    }
    
    .payment-table td {
        padding: 0.75rem 0.3rem;
        font-size: 0.75rem;
    }
}

/* Desktop & Large Tablet - Normal Table Display */
@media (min-width: 768px) {
    .payment-table thead {
        display: table-header-group;
    }
    
    .payment-table tbody {
        display: table-row-group;
    }
    
    .payment-table tr {
        display: table-row;
    }
    
    .payment-table td {
        display: table-cell;
        padding: 0.875rem 0.5rem;
        text-align: center;
        border-bottom: 1px solid #e2e8f0;
        font-weight: 500;
        color: var(--text-primary);
        font-size: 0.9rem;
    }
    
    .payment-table td::before {
        display: none;
    }
}

/* IMPORTANT: Tablet specific styling for 768px-900px - MOVED TO END FOR PRIORITY */
@media (min-width: 768px) and (max-width: 900px) {
    .payment-table {
        font-size: 0.8rem !important;
        min-width: 600px !important;
    }
    
    .payment-table th {
        padding: 0.8rem 0.3rem !important;
        font-size: 0.65rem !important;
        min-height: 50px !important;
        line-height: 1.1 !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow: visible !important;
        text-overflow: visible !important;
        vertical-align: middle !important;
    }
    
    .payment-table td {
        padding: 0.7rem 0.3rem !important;
        font-size: 0.75rem !important;
        text-align: center !important;
    }
    
    .table-responsive {
        overflow-x: auto !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }
} 