/* Chakra Gold Field App - Mobile Styles */

:root {
    --primary: #D4AF37;
    --primary-dark: #B8960F;
    --secondary: #1a2744;
    --secondary-light: #2a3754;
    --background: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--secondary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-icon {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.team-badge {
    background: var(--primary);
    color: var(--secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
}

.logo-section {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.logo-section h1 {
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.logo-section p {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}

.login-form {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input::placeholder {
    color: #aaa;
}

.required {
    color: var(--error);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-primary:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
}

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

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

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
}

.btn-clear {
    background: none;
    border: none;
    color: var(--error);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-remove {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}

/* Error Messages */
.error-message {
    background: #ffe6e6;
    color: var(--error);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Dashboard */
.dashboard-content {
    padding: 16px;
}

.rates-card {
    background: var(--secondary);
    color: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.rates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.rates-date {
    opacity: 0.7;
    font-size: 12px;
}

.rates-body {
    display: flex;
    gap: 24px;
}

.rate-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.rate-label {
    font-size: 12px;
    opacity: 0.7;
    margin-right: 8px;
}

.rate-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.rate-unit {
    font-size: 12px;
    opacity: 0.7;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 16px 12px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Purchase Screen */
.purchase-content {
    padding: 16px;
    padding-bottom: 100px;
}

.form-section {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--secondary);
}

/* Search Results */
.search-results {
    position: absolute;
    width: calc(100% - 32px);
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 50;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-name {
    font-weight: 600;
}

.search-result-details {
    font-size: 12px;
    color: var(--text-light);
}

/* Selected Item */
.selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #e8f5e9;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.selected-info strong {
    display: block;
}

.selected-info span {
    font-size: 12px;
    color: var(--text-light);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
}

.radio-option input {
    width: auto;
}

.radio-option input:checked + span {
    color: var(--primary-dark);
    font-weight: 600;
}

/* Bar Card */
.bar-card {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

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

.bar-title {
    font-weight: 600;
    color: var(--secondary);
}

.bar-preview {
    background: #e3f2fd;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.preview-row + .preview-row {
    margin-top: 6px;
}

/* Preview Screen */
.preview-content {
    padding: 16px;
    padding-bottom: 120px;
}

#preview-details {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

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

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

.preview-section h4 {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.preview-section p {
    font-size: 15px;
}

.preview-bar {
    background: #f5f5f5;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.preview-bar-header {
    font-weight: 600;
    margin-bottom: 4px;
}

.preview-bar-details {
    font-size: 13px;
    color: var(--text-light);
}

.preview-summary {
    background: var(--secondary);
    color: white;
    padding: 16px;
    border-radius: var(--radius);
    margin-top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
}

.summary-row.total {
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 20px;
    font-weight: 700;
}

.summary-row.total .amount {
    color: var(--primary);
}

.preview-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

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

/* Receipt Screen */
.receipt-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.receipt-card {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.receipt-header {
    background: var(--secondary);
    color: white;
    padding: 20px;
    text-align: center;
}

.receipt-header .logo {
    font-size: 32px;
    margin-bottom: 8px;
}

.receipt-header h2 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 4px;
}

.receipt-header .subtitle {
    font-size: 14px;
    opacity: 0.8;
}

.receipt-meta {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.receipt-body {
    padding: 20px;
}

.receipt-section {
    margin-bottom: 16px;
}

.receipt-section h4 {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.receipt-client {
    font-size: 16px;
    font-weight: 600;
}

.receipt-client-details {
    font-size: 13px;
    color: var(--text-light);
}

.receipt-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
}

.receipt-bar:last-child {
    border-bottom: none;
}

.receipt-totals {
    background: #f8f9fa;
    padding: 16px 20px;
}

.receipt-total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.receipt-total-row.main {
    font-size: 22px;
    font-weight: 700;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 2px solid var(--secondary);
}

.receipt-total-row.main .amount {
    color: var(--success);
}

.receipt-footer {
    text-align: center;
    padding: 16px 20px;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
}

.receipt-actions {
    width: 100%;
    max-width: 400px;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.screenshot-hint {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 8px;
}

/* History Screen */
.history-content {
    padding: 16px;
}

.history-item {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.history-invoice {
    font-weight: 600;
    color: var(--secondary);
}

.history-time {
    font-size: 12px;
    color: var(--text-light);
}

.history-client {
    font-size: 15px;
    margin-bottom: 8px;
}

.history-details {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-light);
}

.history-amount {
    font-weight: 600;
    color: var(--success);
}

.history-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 16px;
    font-size: 14px;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .receipt-card {
        box-shadow: none;
        max-width: 100%;
    }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    
    .preview-actions {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
