/* Mobile-first responsive styles */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* Header */
.app-header {
    text-align: center;
    padding: 24px 0 16px;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.app-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 12px;
    color: var(--text-color);
}

.card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.card .note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
    margin-bottom: 0;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-color);
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-full {
    width: 100%;
    margin-top: 16px;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.875rem;
}

.btn .icon {
    font-size: 1.125rem;
}

/* Photo Gallery for Multiple Photos */
.photo-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.photo-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.photo-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-thumbnail .remove-photo {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--error-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-count {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Camera Section */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}

#camera-preview,
#captured-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#photo-canvas {
    display: none;
}

.camera-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.camera-controls .btn {
    flex: 1;
    min-width: calc(50% - 4px);
}

/* Area Entry */
.area-entry {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
}

.area-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.area-entry-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
}

.area-entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.area-entry .form-group {
    margin-bottom: 0;
}

.area-entry .form-group label {
    font-size: 0.75rem;
}

.sqft-calc {
    font-size: 0.7rem;
    color: var(--primary-color);
    font-weight: normal;
    margin-left: 4px;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
}

/* Day Porter Grid */
.day-porter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.day-porter-grid .form-group {
    margin-bottom: 0;
}

/* Fixture Grid */
.fixture-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.fixture-grid .form-group {
    margin-bottom: 0;
}

/* Quote Results */
.quote-total {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-sm);
    color: white;
    margin-bottom: 20px;
}

.quote-total .label {
    display: block;
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.quote-total .price {
    font-size: 2.5rem;
    font-weight: 700;
}

.quote-breakdown {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
}

.quote-breakdown h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.calculation-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.calculation-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.calculation-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 4px 0;
}

.calculation-row.formula {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: white;
    padding: 8px;
    border-radius: 4px;
    margin: 4px 0;
}

.calculation-row.total {
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 8px;
}

.quote-actions {
    display: flex;
    gap: 12px;
}

.quote-actions .btn {
    flex: 1;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loading-message {
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Adjustments */
@media (min-width: 400px) {
    .camera-controls .btn {
        min-width: auto;
        flex: 1;
    }
}

/* Safe Area Support for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #app {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --card-bg: #1e293b;
        --text-color: #f1f5f9;
        --text-muted: #94a3b8;
        --border-color: #334155;
    }

    input[type="text"],
    input[type="number"],
    input[type="password"],
    select {
        background: #0f172a;
    }

    .area-entry,
    .quote-breakdown {
        background: #0f172a;
    }

    .calculation-row.formula {
        background: #334155;
    }

    #loading-overlay {
        background: rgba(15, 23, 42, 0.95);
    }
}
