/* =========================================
   TruthScan App Styles
   ========================================= */

/* App Container (renamed from .container to avoid Tailwind conflict) */
.ts-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
}

/* Home Screen */
.home-screen {
    text-align: center;
    padding-top: 30px;
}

.home-screen h2 {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
}

html.dark .home-screen h2 {
    color: #ffffff;
}

.home-screen p {
    font-size: 15px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 30px;
    padding: 0 10px;
}

html.dark .home-screen p {
    color: #9aa0a6;
}

/* Category Selection */
.category-section {
    margin-bottom: 30px;
}

.category-label {
    font-size: 13px;
    color: #999;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

html.dark .category-label {
    color: #9aa0a6;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

html.dark .category-btn {
    background: #3c4043;
    color: #e8eaed;
}

.category-btn:hover {
    background: #f0f0f0;
}

html.dark .category-btn:hover {
    background: #4a4d51;
}

.category-btn.active {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #2e7d32;
}

html.dark .category-btn.active {
    background: rgba(46, 125, 50, 0.2);
    border-color: #4caf50;
    color: #4caf50;
}

.category-btn svg {
    width: 28px;
    height: 28px;
}

.category-btn.active svg {
    color: #2e7d32;
}

html.dark .category-btn.active svg {
    color: #4caf50;
}

/* Scan Button */
.scan-section {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.scan-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43a047, #2e7d32);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(46, 125, 50, 0.4);
    transition: all 0.3s;
}

.scan-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(46, 125, 50, 0.5);
}

.scan-btn svg {
    width: 32px;
    height: 32px;
    color: white;
}

.scan-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

html.dark .scan-label {
    color: #9aa0a6;
}

/* Hidden file input */
#fileInput {
    display: none;
}

/* Camera Screen */
.camera-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
}

.camera-screen.active {
    display: flex;
    flex-direction: column;
}

.camera-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.close-camera {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
}

.camera-category-badge {
    background: rgba(46, 125, 50, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 20px;
}

.camera-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.capture-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: white;
    border: 4px solid rgba(255,255,255,0.5);
    cursor: pointer;
    transition: all 0.2s;
}

.capture-btn:hover {
    transform: scale(1.05);
}

.gallery-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
}

#canvas {
    display: none;
}

/* Loading Screen */
.loading-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-screen.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e8f5e9;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

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

.loading-text {
    font-size: 16px;
    color: #666;
    text-align: center;
}

.loading-subtext {
    font-size: 14px;
    color: #999;
    margin-top: 8px;
}

/* Results Screen */
.results-screen {
    display: none;
}

.results-screen.active {
    display: block;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0 20px;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.product-name {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    padding-right: 40px;
}

.product-category-badge {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 4px;
}

/* Score Card */
.score-card {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 24px;
    text-align: center;
}

.score-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    position: relative;
}

.score-circle svg {
    transform: rotate(-90deg);
}

.score-circle-bg {
    fill: none;
    stroke: #c8e6c9;
    stroke-width: 8;
}

.score-circle-fill {
    fill: none;
    stroke: #2e7d32;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-circle-fill.warning {
    stroke: #f57c00;
}

.score-circle-fill.danger {
    stroke: #d32f2f;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    font-weight: 700;
    color: #2e7d32;
}

.score-value.warning {
    color: #f57c00;
}

.score-value.danger {
    color: #d32f2f;
}

.score-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-label {
    font-size: 14px;
    color: #666;
}

.metric-bar {
    flex: 1;
    height: 6px;
    background: #c8e6c9;
    border-radius: 3px;
    margin: 0 12px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    background: #2e7d32;
    border-radius: 3px;
    transition: width 1s ease;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
    min-width: 30px;
    text-align: right;
}

.score-source {
    font-size: 12px;
    color: #999;
    margin-top: 16px;
}

/* Sections */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 16px;
}

/* Ingredients List */
.ingredient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
}

.ingredient-info {
    flex: 1;
}

.ingredient-name {
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.ingredient-risk {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.risk-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.risk-low {
    color: #2e7d32;
}

.risk-low .risk-icon {
    background: #e8f5e9;
}

.risk-some {
    color: #f57c00;
}

.risk-some .risk-icon {
    background: #fff3e0;
}

.risk-high {
    color: #d32f2f;
}

.risk-high .risk-icon {
    background: #ffebee;
}

.info-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
}

/* Ingredient Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 480px;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

/* Alternatives */
.alternatives-category {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.alternatives-desc {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.alternatives-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.alternative-card {
    flex: 0 0 160px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.alternative-image {
    width: 100%;
    height: 120px;
    background: #f5f5f5;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alternative-image img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.alternative-score {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 2px solid #2e7d32;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #2e7d32;
}

.alternative-info {
    padding: 12px;
}

.alternative-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alternative-brand {
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
}

.alternative-price {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
}

/* Summary Section */
.summary-card {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.summary-text {
    font-size: 14px;
    color: #666;
    line-height: 1.7;
}

/* Warnings */
.warnings-section {
    background: #fff3e0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.warnings-section.danger {
    background: #ffebee;
}

.warnings-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #e65100;
    margin-bottom: 12px;
}

.warnings-section.danger .warnings-title {
    color: #c62828;
}

.warning-item {
    font-size: 14px;
    color: #666;
    padding: 8px 0;
    border-bottom: 1px solid rgba(230, 81, 0, 0.1);
}

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

/* Concerns Section */
.concerns-section {
    background: #fce4ec;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.concerns-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #ad1457;
    margin-bottom: 12px;
}

.concern-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(173, 20, 87, 0.1);
}

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

.concern-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #ad1457;
}

.concern-text {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.concern-name {
    font-weight: 600;
    color: #ad1457;
}

/* Error Modal */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.error-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 320px;
    text-align: center;
    margin: 20px;
}

.error-icon {
    margin-bottom: 16px;
}

.error-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.error-content p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    word-break: break-word;
}

.error-content button {
    background: #2e7d32;
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.error-content button:hover {
    background: #1b5e20;
}

/* Responsive */
@media (max-width: 380px) {
    .ts-container {
        padding: 16px;
    }

    .home-screen h2 {
        font-size: 22px;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .score-circle {
        width: 100px;
        height: 100px;
    }

    .score-value {
        font-size: 28px;
    }
}
