:root {
    --primary-color: #ff4081;
    --primary-gradient: linear-gradient(135deg, #ff4081, #ff6699);
    --secondary-color: #536dfe;
    --secondary-gradient: linear-gradient(135deg, #536dfe, #7986cb);
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --danger-gradient: linear-gradient(135deg, #f44336, #ff7961);
    --gray-color: #6c757d;
    --emphasis-color: #673ab7;
    --highlight-bg: #fff3cd;
    --number-color: #0288d1;
    --card-shadow: 0 8px 20px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 12px 30px rgba(0,0,0,0.15);
    --border-radius: 12px;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background-color: #f5f7fa;
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--primary-gradient);
    color: white;
    text-align: center;
    padding: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,100 Z" fill="rgba(255,255,255,0.05)"/></svg>');
    background-size: cover;
    z-index: 0;
}

.app-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.app-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.info-section {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--secondary-color);
}

.info-section h2 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.info-section p {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

#api-key-section, #vision-api-key-section, #emergency-contact-section {
    transition: all 0.3s ease;
    transform-origin: center top;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--secondary-color);
}

.panic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
    padding: 2rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

/* Panic Button Styles */
.panic-button {
    width: 220px;
    height: 220px;
    background: var(--danger-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 10px 30px rgba(244, 67, 54, 0.4);
    outline: none;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
    line-height: 1.3;
    margin: 2rem 0;
    letter-spacing: 1px;
}

.panic-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(244,67,54,0) 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.panic-button:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 15px 35px rgba(244, 67, 54, 0.5);
}

.panic-button:hover::before {
    opacity: 1;
}

.panic-button:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

.panic-button.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.8);
    }
    70% {
        box-shadow: 0 0 0 30px rgba(244, 67, 54, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
    }
}

.emergency-text {
    color: var(--danger-color);
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 1rem;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sms-notice {
    background-color: rgba(33, 150, 243, 0.1);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    max-width: 80%;
    text-align: center;
    border-left: 3px solid var(--secondary-color);
}

/* Alert Analysis Section */
.alert-analysis {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    display: none; /* Initially hidden */
    border-top: 5px solid var(--secondary-color);
    transition: all 0.3s ease;
}

.alert-analysis.active {
    display: block;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.alert-animation {
    animation: alertPulse 1.5s ease-out;
}

@keyframes alertPulse {
    0% { box-shadow: var(--card-shadow); }
    50% { box-shadow: 0 0 0 10px rgba(83, 109, 254, 0.1); }
    100% { box-shadow: var(--card-shadow); }
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #f1f1f1;
}

.alert-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--secondary-color);
    position: relative;
}

.alert-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--secondary-color);
    border-radius: 3px;
}

.alert-timestamp {
    font-size: 0.95rem;
    color: var(--gray-color);
    background-color: rgba(108, 117, 125, 0.1);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

.alert-content {
    display: grid;
    grid-template-columns: 180px 1fr;
    grid-gap: 2rem;
}

.alert-image {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.alert-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.alert-details {
    display: flex;
    flex-direction: column;
}

.threat-level {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    letter-spacing: 0.5px;
}

.threat-low {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(76, 175, 80, 0.1));
    color: var(--success-color);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.threat-medium {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.2), rgba(255, 152, 0, 0.1));
    color: var(--warning-color);
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.threat-high {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.2), rgba(244, 67, 54, 0.1));
    color: var(--danger-color);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Enhanced Recommendation and Reasoning Styles */
.recommendation, #reasoning {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    color: #333;
}

.recommendation p, #reasoning p {
    margin-bottom: 1.2rem;
}

.recommendation strong, #reasoning strong {
    color: var(--emphasis-color);
    font-weight: 700;
}

.recommendation em, #reasoning em {
    font-style: italic;
    font-weight: 600;
    color: #444;
}

.highlight-warning {
    color: var(--danger-color);
    background-color: rgba(244, 67, 54, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-weight: 700;
}

.highlight-number {
    color: var(--number-color);
    background-color: rgba(2, 136, 209, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-weight: 700;
}

/* Enhanced Alert Card Styles */
.alert-card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.alert-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
}

.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.alert-card-content {
    padding: 1.5rem;
    line-height: 1.6;
}

.alert-card-content p {
    margin-bottom: 1rem;
}

.alert-card-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
}

/* Object Tags */
.object-tag {
    display: inline-block;
    background-color: #f1f5f9;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    margin: 0.2rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.object-tag:hover {
    background-color: #e2e8f0;
    transform: translateY(-2px);
}

.object-tag.dangerous {
    background-color: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.object-tag.dangerous:hover {
    background-color: rgba(244, 67, 54, 0.15);
}

/* Warning Message */
.detection-warning {
    background-color: rgba(244, 67, 54, 0.05);
    border-left: 3px solid var(--danger-color);
    padding: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-weight: 600;
    color: var(--danger-color);
    display: none;
    animation: slideIn 0.5s forwards;
}

.detection-warning.active {
    display: block;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .alert-content {
        grid-template-columns: 1fr;
    }
    
    .alert-image {
        width: 100%;
        height: auto;
        max-height: 250px;
        margin-bottom: 1.5rem;
    }
    
    main {
        padding: 1.5rem 1rem;
    }
    
    .panic-button {
        width: 180px;
        height: 180px;
        font-size: 1.2rem;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .alert-title {
        font-size: 1.4rem;
    }
    
    .sms-notice {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .alert-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .alert-timestamp {
        margin-top: 0.5rem;
    }
    
    .panic-button {
        width: 150px;
        height: 150px;
        font-size: 1.1rem;
        padding: 0 10px;
    }
    
    .alert-card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .alert-card-header .threat-level {
        margin-bottom: 0.5rem;
    }
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(3px);
}

.loading.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.spinner {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 15px rgba(255, 64, 129, 0.5);
}

.loading p {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 80%;
}

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

/* Camera Section */
.camera-section {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    margin-bottom: 2rem;
    overflow: hidden;
    border-radius: var(--border-radius);
    display: none;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.camera-section.active {
    display: block;
    animation: fadeInUp 0.5s ease;
}

#camera-stream {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
}

/* Error Message */
.error-message {
    max-width: 100%;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    display: none;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    transform-origin: center top;
    transition: all 0.3s ease;
    border-left: 4px solid var(--danger-color);
}

.error-message.active {
    display: block;
    animation: slideInDown 0.5s ease;
}

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Previous Alerts */
.previous-alerts {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    border-top: 5px solid var(--primary-color);
}

.previous-alerts h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    font-weight: 800;
    position: relative;
    display: inline-block;
}

.previous-alerts h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

.alerts-list {
    position: relative;
}

.alerts-list > p {
    padding: 2rem;
    text-align: center;
    color: var(--gray-color);
    background-color: #f9f9f9;
    border-radius: var(--border-radius);
}

/* Location Info */
.location-info {
    display: flex;
    align-items: center;
    background-color: #f5f7fa;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.location-info svg {
    color: var(--secondary-color);
    margin-right: 0.5rem;
    flex-shrink: 0;
}

#location-text {
    font-size: 0.9rem;
    font-family: monospace;
    color: #555;
}

/* Object Detection Styles */
.object-detection {
    margin: 1.5rem 0;
    background-color: #f8f9fa;
    padding: 1.2rem;
    border-radius: var(--border-radius);
    display: none;
    border-left: 3px solid var(--secondary-color);
}

.object-detection.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.detected-objects-title {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.detected-objects-title::before {
    content: '🔍';
    margin-right: 0.5rem;
}

.objects-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

/* Footer styling */
footer {
    background: var(--primary-gradient);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    font-size: 0.95rem;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
    position: relative;
}

/* Form inputs styling */
input[type="text"], 
input[type="password"], 
input[type="tel"], 
input[type="email"] {
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    width: 100%;
}

input[type="text"]:focus, 
input[type="password"]:focus, 
input[type="tel"]:focus, 
input[type="email"]:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(83, 109, 254, 0.2);
    outline: none;
}

button {
    cursor: pointer;
    padding: 0.8rem 1.5rem;
    background: var(--secondary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(83, 109, 254, 0.3);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.4s ease;
    z-index: -1;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(83, 109, 254, 0.4);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(83, 109, 254, 0.2);
}

/* Settings Button Styles */
.settings-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 25px;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.settings-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.settings-toggle svg {
    width: 16px;
    height: 16px;
}

/* Settings Container */
.settings-container {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-top: 5px solid var(--secondary-color);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.settings-container.active {
    max-height: 1500px;
    opacity: 1;
    padding: 1.5rem;
}