/* === VARIABLES === */
/* === WHITE THEME === */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #4a5568;
    --primary: #0066CC;
    --accent: #00CCFF;
    --border: #e2e8f0;
    --severe: #dc2626;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    overflow-x: hidden;
}

/* Canvas background */
#canvas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #ffffff 0%, #f0f4f8 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    padding: 3rem 0;
    position: relative;
}

.logo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: block;
    box-shadow: 0 10px 40px rgba(0, 102, 204, 0.2);
    animation: breatheLogo 4s ease-in-out infinite;
}

@keyframes breatheLogo {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 40px rgba(0, 102, 204, 0.2);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 15px 60px rgba(0, 204, 255, 0.4);
    }
}

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 0.5rem;
}

/* Cards */
.analyzer, .results {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

.input-section {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

textarea, input[type="text"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text);
    transition: all 0.3s ease;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 204, 255, 0.1);
}

textarea {
    min-height: 200px;
    resize: vertical;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 1.2rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-size: 200% 200%;
    animation: breatheGradient 4s ease-in-out infinite;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 102, 204, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Results */
.results {
    background: white;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.results-header h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin: 0;
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 0 1rem;
    color: var(--text-secondary);
}

.four-laws {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.four-laws span {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.hidden {
    display: none;
}

@keyframes btn-breathe {
    0%, 100% { 
        box-shadow: 
            0 4px 20px rgba(0, 102, 204, 0.4),
            0 0 40px rgba(0, 204, 255, 0.2);
        transform: scale(1);
    }
    50% { 
        box-shadow: 
            0 6px 28px rgba(0, 102, 204, 0.5),
            0 0 50px rgba(0, 204, 255, 0.3);
        transform: scale(1.01);
    }
}

.btn-primary:hover:not(:disabled) {
    animation-play-state: paused;
    box-shadow: 
        0 8px 32px rgba(0, 204, 255, 0.6),
        0 0 60px rgba(0, 204, 255, 0.4);
    transform: translateY(-3px) scale(1.02);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    animation: none;
}

.btn-secondary {
    background: rgba(15, 20, 41, 0.8);
    border: 2px solid var(--accent);
    color: var(--accent);
    animation: breathe-border 6s ease-in-out infinite;
}

.btn-secondary:hover {
    background: var(--accent);
    color: var(--bg-dark);
    transform: translateY(-2px);
}

/* === RESULTS === */
.results {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}

.results.hidden {
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.results-header h2 {
    font-size: 1.75rem;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(0, 204, 255, 0.5);
}

/* === ANALYSIS GRID === */
#analysis-output {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
    padding: 0;
}

.analysis-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    animation: slideIn 0.6s ease forwards, card-breathe 8s ease-in-out infinite;
    opacity: 0;
    position: relative;
    overflow: hidden;
}

@keyframes card-breathe {
    0%, 100% { 
        box-shadow: 
            0 4px 16px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(0, 204, 255, 0.1);
    }
    50% { 
        box-shadow: 
            0 6px 24px rgba(0, 0, 0, 0.4),
            0 0 0 1px rgba(0, 204, 255, 0.25);
    }
}

.analysis-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent), var(--primary));
    background-size: 100% 200%;
    animation: gradient-vertical 3s ease infinite;
}

@keyframes gradient-vertical {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 0% 100%; }
}

.analysis-card.structural::before {
    background: linear-gradient(180deg, var(--primary), var(--accent), var(--primary));
    background-size: 100% 300%;
}

.analysis-card.severe::before {
    background: linear-gradient(180deg, var(--severe), #ff8787, var(--severe));
    background-size: 100% 300%;
}

.analysis-card.warning::before {
    background: linear-gradient(180deg, var(--moderate), #ffe66d, var(--moderate));
    background-size: 100% 300%;
}

.analysis-card.laws::before {
    background: linear-gradient(180deg, #0066CC, #00CCFF, #51cf66, #00CCFF, #0066CC);
    background-size: 100% 400%;
}

.analysis-card.cascade::before {
    background: linear-gradient(180deg, var(--accent), var(--primary), var(--accent));
    background-size: 100% 300%;
}

.analysis-card.architecture::before {
    background: linear-gradient(180deg, var(--severe), var(--moderate), var(--severe));
    background-size: 100% 300%;
}

.analysis-card:nth-child(1) { animation-delay: 0.1s; }
.analysis-card:nth-child(2) { animation-delay: 0.2s; }
.analysis-card:nth-child(3) { animation-delay: 0.3s; }
.analysis-card:nth-child(4) { animation-delay: 0.4s; }
.analysis-card:nth-child(5) { animation-delay: 0.5s; }
.analysis-card:nth-child(6) { animation-delay: 0.6s; }

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

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.card-body {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 0.9rem;
}

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

.card-body strong {
    color: var(--accent);
    font-weight: 600;
}

.card-body em {
    color: var(--text-secondary);
    font-style: italic;
}

.analysis-card:hover {
    animation-play-state: paused;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(0, 204, 255, 0.4);
}

/* === FOOTER === */
.footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}

.four-laws {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.four-laws span {
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.3s;
}

.four-laws span:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(0, 204, 255, 0.3);
    transform: translateY(-2px);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    #analysis-output {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2.2rem;
    }
    
    .logo {
        width: 100px;
        height: 100px;
    }
    
    .analyzer {
        padding: 1.5rem;
    }
    
    .analysis-card {
        padding: 1.5rem;
    }
    
    .four-laws {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .results-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .btn-secondary {
        width: 100%;
    }
}

/* === PDF MODAL === */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pdf-modal.hidden {
    display: none;
}

.pdf-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    box-shadow: 0 0 60px rgba(0, 204, 255, 0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.pdf-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pdf-modal-content h3 {
    color: var(--accent);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.pdf-modal-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* === V0.4 NEW ELEMENTS === */

/* Orientation Line */
.orientation-line {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.1), rgba(0, 204, 255, 0.1));
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Severity Blockquote */
.severity-card blockquote.severity-level {
    margin: 1rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
}

.severity-level.severe {
    border-color: #ff4444;
    color: #ff6666;
    background: rgba(255, 68, 68, 0.1);
}

.severity-level.significant {
    border-color: #ff9933;
    color: #ffaa55;
    background: rgba(255, 153, 51, 0.1);
}

.severity-level.minor {
    border-color: #ffcc00;
    color: #ffdd33;
    background: rgba(255, 204, 0, 0.1);
}

.severity-level.compliant {
    border-color: #00cc66;
    color: #00ff88;
    background: rgba(0, 204, 102, 0.1);
}

/* Laws List */
.laws-intro {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.laws-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.law-item {
    padding: 1rem;
    background: rgba(0, 102, 204, 0.05);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
}

.law-item h4 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.law-item p {
    color: var(--text);
    line-height: 1.6;
}

#analysis-output h3 {
    color: var(--primary);
    font-size: 1.2rem;
    margin: 1.5rem 0 0.75rem 0;
}

#analysis-output h4 {
    color: var(--accent);
    font-size: 1rem;
    margin: 1rem 0 0.5rem 0;
}

#analysis-output p {
    margin: 0.75rem 0;
    line-height: 1.7;
}

#analysis-output em {
    color: var(--text-secondary);
    font-style: italic;
}

#analysis-output strong {
    color: var(--accent);
    font-weight: 600;
}

#analysis-output blockquote {
    margin: 1rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent);
    background: rgba(0, 204, 255, 0.1);
    border-radius: 4px;
}

#analysis-output blockquote.severity-callout {
    font-weight: bold;
    font-size: 1.05rem;
}

#analysis-output blockquote strong {
    color: #ffaa55;
}

/* === MARKDOWN OUTPUT STYLING === */
#analysis-output {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7;
    color: var(--text);
    max-width: 900px;
    margin: 0 auto;
}

/* Orientation line (italic paragraph at start) */
#analysis-output p:first-child em {
    display: block;
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.15), rgba(0, 204, 255, 0.15));
    border-left: 4px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 0 0 2rem 0;
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Main section headings (##) */
#analysis-output h2 {
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 3rem 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--accent);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#analysis-output h2:first-of-type {
    margin-top: 1rem;
}

/* Sub-headings (###) - Four Laws */
#analysis-output h3 {
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    padding-left: 1rem;
    border-left: 4px solid var(--primary);
    background: rgba(0, 102, 204, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 4px;
}

/* Paragraphs */
#analysis-output p {
    margin: 1rem 0;
    line-height: 1.8;
    font-size: 1rem;
}

/* Emphasis */
#analysis-output em {
    color: var(--text-secondary);
    font-style: italic;
}

#analysis-output strong {
    color: var(--accent);
    font-weight: 600;
}

/* Blockquotes - Severity */
#analysis-output blockquote {
    margin: 1.5rem 0;
    padding: 1.25rem 1.75rem;
    border-left: 5px solid var(--accent);
    background: linear-gradient(135deg, rgba(0, 204, 255, 0.1), rgba(0, 102, 204, 0.05));
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.05rem;
}

#analysis-output blockquote p {
    margin: 0;
}

#analysis-output blockquote strong {
    color: #ffaa55;
    font-size: 1.1rem;
}

/* Severity colors */
#analysis-output blockquote:has(strong:contains("Severe")) {
    border-color: #ff4444;
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.15), rgba(255, 68, 68, 0.05));
}

#analysis-output blockquote:has(strong:contains("Significant")) {
    border-color: #ff9933;
    background: linear-gradient(135deg, rgba(255, 153, 51, 0.15), rgba(255, 153, 51, 0.05));
}

/* Horizontal rules */
#analysis-output hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2rem 0;
    opacity: 0.3;
}

/* Lists */
#analysis-output ul, #analysis-output ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

#analysis-output li {
    margin: 0.5rem 0;
    line-height: 1.7;
}

/* Code (if any) */
#analysis-output code {
    background: rgba(0, 204, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Smooth scroll within output */
#analysis-output {
    scroll-behavior: smooth;
}

/* === ACTION BUTTONS WITH BREATHING GRADIENT === */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-action {
    position: relative;
    padding: 0.9rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-action.btn-gradient {
    background: linear-gradient(135deg, 
        var(--primary) 0%, 
        var(--accent) 50%, 
        var(--primary) 100%);
    background-size: 200% 200%;
    animation: breatheGradient 4s ease-in-out infinite;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 204, 255, 0.4);
}

.btn-action.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 204, 255, 0.6);
    animation-duration: 2s;
}

.btn-action.btn-gradient:active {
    transform: translateY(0);
}

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

/* Success state */
.btn-action.success {
    background: linear-gradient(135deg, #00cc66, #00ff88) !important;
    animation: none !important;
}

@keyframes breatheGradient {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-action {
        width: 100%;
        justify-content: center;
    }
}
