/**
 * Zomato & Swiggy Calculator Pro - Mobile-First CSS
 * 
 * @package ZomatoSwiggyCalculatorPro
 * @since 1.0.0
 */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

.zsc-calculator {
    width: 95%;
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Tabs */
.zsc-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.zsc-tab {
    flex: 1;
    min-width: 100px;
    padding: 16px 8px;
    text-align: center;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.zsc-tab:hover {
    background: #e9ecef;
    color: #495057;
}

.zsc-tab.active {
    color: #007bff;
    background: #fff;
    border-bottom: 2px solid #007bff;
}

.zsc-tab-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zsc-tab-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.zsc-tab.active .zsc-tab-icon img {
    opacity: 1;
}

.zsc-tab:not(.active) .zsc-tab-icon img {
    opacity: 0.6;
}

.zsc-tab-text {
    font-size: 12px;
    line-height: 1;
}

/* Content */
.zsc-content {
    padding: 20px;
}

.zsc-tab-content {
    display: none;
}

.zsc-tab-content.active {
    display: block;
}

/* Form Elements */
.zsc-input-group {
    margin-bottom: 20px;
}

.zsc-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.zsc-suggestion {
    display: block;
    font-size: 12px;
    color: #6c757d;
    font-weight: normal;
    margin-top: 2px;
}

.zsc-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.zsc-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.zsc-input:invalid {
    border-color: #dc3545;
}

.zsc-input-row {
    display: flex;
    gap: 8px;
}

.zsc-input-row .zsc-input {
    flex: 1;
}

/* Tip Suggestions */
.zsc-tip-suggestions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.zsc-tip-btn {
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
}

.zsc-tip-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.zsc-tip-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
}

/* Buttons */
.zsc-button {
    width: 100%;
    padding: 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-bottom: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.zsc-button:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.zsc-button:active {
    transform: translateY(0);
}

.zsc-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* Result Card */
.zsc-result-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.zsc-result-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
    text-align: center;
}

.zsc-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
}

.zsc-result-item:last-child {
    border-bottom: none;
    font-weight: 600;
    font-size: 18px;
    color: #007bff;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 2px solid #007bff;
}

.zsc-result-label {
    color: #6c757d;
}

.zsc-result-value {
    font-weight: 500;
    color: #333;
}

/* Actions */
.zsc-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.zsc-action-btn {
    flex: 1;
    min-width: 80px;
    padding: 12px 16px;
    border: 2px solid #007bff;
    background: white;
    color: #007bff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
}

.zsc-action-btn:hover {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
}

.zsc-action-btn:active {
    transform: translateY(0);
}

/* Data Info */
.zsc-data-info {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.zsc-data-info small {
    color: #6c757d;
    font-size: 12px;
}

.zsc-data-sources-link {
    color: #007bff;
    text-decoration: none;
}

.zsc-data-sources-link:hover {
    text-decoration: underline;
}

/* Modal */
.zsc-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.zsc-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.zsc-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zsc-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.zsc-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.zsc-modal-close:hover {
    background: #f8f9fa;
    color: #333;
}

.zsc-modal-body {
    padding: 20px;
}

/* Sources List */
.zsc-sources-list {
    max-height: 400px;
    overflow-y: auto;
}

.zsc-source-item {
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
}

.zsc-source-item:last-child {
    border-bottom: none;
}

.zsc-source-item h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.zsc-source-item h4 a {
    color: #007bff;
    text-decoration: none;
}

.zsc-source-item h4 a:hover {
    text-decoration: underline;
}

.zsc-source-item p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #6c757d;
}

.zsc-source-item small {
    font-size: 11px;
    color: #adb5bd;
}

/* Privacy Notice */
.zsc-privacy-notice {
    margin-top: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
}

.zsc-privacy-notice small {
    color: #6c757d;
    font-size: 12px;
}

.zsc-privacy-link {
    color: #007bff;
    text-decoration: none;
}

.zsc-privacy-link:hover {
    text-decoration: underline;
}

/* Loading States */
.zsc-loading {
    opacity: 0.6;
    pointer-events: none;
}

.zsc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.zsc-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #f5c6cb;
}

.zsc-success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid #c3e6cb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .zsc-calculator {
        width: 95%;
        margin: 10px auto;
        border-radius: 8px;
    }
    
    .zsc-tab {
        padding: 12px 4px;
        font-size: 12px;
        min-width: 80px;
    }
    
    .zsc-tab-icon {
        font-size: 16px;
    }
    
    .zsc-tab-text {
        font-size: 10px;
    }
    
    .zsc-content {
        padding: 16px;
    }
    
    .zsc-input {
        font-size: 16px;
        padding: 14px 16px;
    }
    
    .zsc-button {
        padding: 16px;
        font-size: 16px;
    }
    
    .zsc-result-card {
        padding: 16px;
    }
    
    .zsc-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .zsc-action-btn {
        width: 100%;
    }
    
    .zsc-modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .zsc-modal-header,
    .zsc-modal-body {
        padding: 16px;
    }
    
    .zsc-tip-suggestions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .zsc-calculator {
        width: 100%;
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    .zsc-tabs {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    .zsc-content {
        padding-top: 80px;
        padding-bottom: 20px;
    }
    
    .zsc-input-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .zsc-result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .zsc-result-value {
        font-weight: 600;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .zsc-calculator {
        border: 2px solid #000;
    }
    
    .zsc-tab.active {
        background: #000;
        color: #fff;
    }
    
    .zsc-button {
        background: #000;
        border: 2px solid #000;
    }
    
    .zsc-button:hover {
        background: #333;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Breakdown Container */
.zsc-breakdown-container {
    margin-top: 20px;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.zsc-breakdown-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.zsc-breakdown-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.zsc-breakdown-tab:hover {
    color: #007bff;
    background: #f8f9fa;
}

.zsc-breakdown-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background: #fff;
}

.zsc-breakdown-content {
    position: relative;
}

.zsc-breakdown-panel {
    display: none;
    min-height: 300px;
}

.zsc-breakdown-panel.active {
    display: block;
}

/* Chart Styles */
#breakdown-chart-canvas {
    max-width: 100%;
    height: 300px;
    margin: 0 auto;
}

/* Table Styles */
.zsc-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.zsc-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.zsc-breakdown-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.zsc-breakdown-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.zsc-breakdown-table tr:last-child td {
    border-bottom: none;
}

.zsc-table-total {
    background: #f8f9fa;
    font-weight: 600;
}

.zsc-table-total td {
    border-top: 2px solid #007bff;
    color: #007bff;
}

.zsc-table-amount {
    text-align: right;
    font-weight: 500;
}

.zsc-table-amount.negative {
    color: #dc3545;
}

.zsc-table-percentage {
    text-align: right;
    color: #6c757d;
    font-size: 13px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .zsc-breakdown-tabs {
        flex-direction: column;
    }
    
    .zsc-breakdown-tab {
        border-bottom: 1px solid #e9ecef;
        border-right: 2px solid transparent;
    }
    
    .zsc-breakdown-tab.active {
        border-bottom-color: #e9ecef;
        border-right-color: #007bff;
    }
    
    .zsc-breakdown-table {
        font-size: 12px;
    }
    
    .zsc-breakdown-table th,
    .zsc-breakdown-table td {
        padding: 8px 12px;
    }
    
    #breakdown-chart-canvas {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .zsc-breakdown-container {
        margin-top: 16px;
        padding-top: 16px;
    }
    
    .zsc-breakdown-tab {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .zsc-breakdown-table th,
    .zsc-breakdown-table td {
        padding: 6px 8px;
    }
    
    #breakdown-chart-canvas {
        height: 200px;
    }
}

/* Print Styles */
@media print {
    .zsc-tabs,
    .zsc-actions,
    .zsc-modal,
    .zsc-breakdown-tabs {
        display: none !important;
    }
    
    .zsc-calculator {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .zsc-result-card {
        background: #fff !important;
        border: 1px solid #000;
    }
    
    .zsc-breakdown-panel {
        display: block !important;
    }
    
    .zsc-breakdown-table {
        border: 1px solid #000;
    }
    
    .zsc-breakdown-table th,
    .zsc-breakdown-table td {
        border: 1px solid #000;
    }
}
