/* ============================================
   RESPONSIVE MOBILE-FIRST CSS FOR KAVSAR MED
   ============================================ */

:root {
    --primary-color: #3b82f6;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 25px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============== HEADER ============== */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
}

/* ============== MAIN CONTENT ============== */
.app-main {
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============== CARDS ============== */
.card {
    background: var(--bg-white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h3 {
    font-size: 1.125rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}

/* ============== FORMS ============== */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============== BUTTONS ============== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 100%;
}

/* ============== TABLE ============== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.375rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
}

.data-table tbody tr:hover {
    background: var(--bg-light);
}

/* ============== STATISTICS GRID ============== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.stat-info h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-info h3 {
    font-size: 1.75rem;
    color: var(--text-main);
    font-weight: 700;
    margin: 0;
}

/* ============== MODAL ============== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 1rem;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
    flex: 1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ============== SERVICES GRID ============== */
.services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-service {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 0.875rem;
}

.btn-service span {
    display: block;
}

.btn-service span:first-child {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.btn-service .price {
    color: var(--success-color);
    font-weight: 700;
    font-size: 0.875rem;
}

.btn-service:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.btn-service.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

/* ============== SERVICES TABLE ============== */
.services-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.services-table th,
.services-table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.services-table th:first-child,
.services-table td:first-child {
    text-align: left;
}

.services-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-main);
}

/* ============== SEARCH BOX ============== */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    gap: 0.5rem;
}

.search-box i {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 0.875rem;
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card-header > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ============== PRINT AREA ============== */
.print-area {
    display: none;
}

.no-print {
    print: none;
}

@media print {
    .no-print {
        display: none !important;
    }
    .print-area {
        display: block;
    }
}

/* ============== UTILITY CLASSES ============== */
.history-scroll {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
}

.history-item {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ============== TABLET VIEW (640PX AND UP) ============== */
@media (min-width: 640px) {
    .app-header {
        padding: 1.25rem 1.5rem;
    }

    .app-main {
        padding: 1.5rem;
    }

    .card {
        padding: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .tabs {
        gap: 1rem;
    }

    .tab-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.95rem;
    }

    .services-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .card-header > div:first-child {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .search-box {
        margin-top: 0;
        flex: 1;
    }

    .modal-content {
        max-width: 700px;
    }
}

/* ============== DESKTOP VIEW (1024PX AND UP) ============== */
@media (min-width: 1024px) {
    .app-header {
        gap: 3rem;
    }

    .app-main {
        padding: 2rem;
    }

    .card {
        padding: 2.5rem;
    }

    .form-row {
        grid-template-columns: 1fr 1fr;
    }

    .services-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    .modal-content {
        max-width: 800px;
        max-height: 85vh;
    }

    .data-table {
        font-size: 0.95rem;
    }

    .data-table th,
    .data-table td {
        padding: 1.25rem;
    }

    .services-table th,
    .services-table td {
        padding: 1rem;
    }
}

/* ============== LARGE DESKTOP (1280PX AND UP) ============== */
@media (min-width: 1280px) {
    .app-container {
        max-width: 1400px;
        margin: 0 auto;
    }

    .card {
        padding: 3rem;
    }

    .form-row {
        gap: 2rem;
    }

    .services-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============== ORIENTATION FIXES ============== */
@media (max-height: 700px) and (orientation: landscape) {
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    .card {
        padding: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* ============== TOUCH DEVICE OPTIMIZATIONS ============== */
@media (hover: none) and (pointer: coarse) {
    button {
        min-height: 44px;
        min-width: 44px;
    }

    .tab-btn {
        min-height: 44px;
    }

    input,
    select {
        min-height: 44px;
    }
}

/* ============== HIGH DPI SCREEN SUPPORT ============== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    border {
        border-width: 0.5px;
    }
}
