/* style.css - Enhanced with Dark Mode, Calculator UI, Modal Styles */

/* ===== CSS VARIABLES ===== */
:root {
    --primary-color: #1e3c72;
    --primary-dark: #0f2744;
    --primary-light: #2a4a82;
    --secondary-color: #f4b400;
    --accent-color: #2a7f62;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #dee2e6;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --hover-shadow: 0 8px 25px rgba(0,0,0,0.15);
    
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition: all 0.3s ease;
}

/* ===== DARK MODE VARIABLES ===== */
.dark-mode {
    --primary-color: #2c3e50;
    --primary-dark: #1a2632;
    --primary-light: #34495e;
    
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #f0f0f0;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --border-color: #404040;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    line-height: 1.3;
    font-weight: 600;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; color: var(--primary-color); }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* ===== HEADER ===== */
.site-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-area {
    flex: 2;
    min-width: 300px;
}

.site-title {
    font-size: 2.2rem;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-title i {
    color: var(--secondary-color);
    font-size: 2.5rem;
}

.site-title span {
    font-size: 1.2rem;
    font-weight: 400;
    opacity: 0.9;
}

.header-controls {
    flex: 1;
    min-width: 350px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-search {
    flex: 1;
    display: flex;
    gap: 8px;
}

.header-search input {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 40px;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.header-search input:focus {
    box-shadow: 0 0 0 3px rgba(244, 180, 0, 0.3);
}

.header-search button {
    width: 50px;
    border-radius: 50%;
    border: none;
    background-color: var(--secondary-color);
    color: var(--primary-dark);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.header-search button:hover {
    transform: scale(1.05);
    background-color: #ffc107;
}

.dark-mode-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid white;
    background: transparent;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.dark-mode-btn .fa-sun { display: none; }
.dark-mode .dark-mode-btn .fa-moon { display: none; }
.dark-mode .dark-mode-btn .fa-sun { display: block; color: #ffd700; }

/* ===== NAVIGATION ===== */
.main-nav {
    background-color: var(--bg-primary);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 80px;
    z-index: 99;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 5px;
    padding: 10px 0;
}

.nav-menu li a {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    border-radius: 30px;
    transition: var(--transition);
}

.nav-menu li a:hover,
.nav-menu li a.active {
    background-color: var(--primary-color);
    color: white;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: 2px solid var(--primary-color);
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    border-radius: 40px;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

/* ===== INTRO SECTION ===== */
.intro-section {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 16px;
    margin: 30px 0;
    box-shadow: var(--card-shadow);
}

.quick-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 25px;
}

.quick-stats span {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary-color);
}

.quick-stats i {
    font-size: 1.8rem;
    color: var(--accent-color);
}

/* ===== CHAPTERS GRID ===== */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.chapter-card {
    background: var(--bg-primary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

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

.chapter-header {
    background: linear-gradient(145deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chapter-number {
    font-size: 2.2rem;
    font-weight: 700;
    min-width: 80px;
    text-align: center;
    color: var(--secondary-color);
}

.chapter-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.chapter-body {
    padding: 20px;
    flex-grow: 1;
}

.chapter-ref {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
}

.chapter-applicability {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.app-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-building { background: #e3f2fd; color: #0d47a1; }
.badge-road { background: #e8f5e8; color: #1b5e20; }
.badge-industrial { background: #fff3e0; color: #b45f06; }
.badge-foundation { background: #ede7f6; color: #4a148c; }

.dark-mode .badge-building { background: #0d47a1; color: #e3f2fd; }
.dark-mode .badge-road { background: #1b5e20; color: #e8f5e8; }
.dark-mode .badge-industrial { background: #b45f06; color: #fff3e0; }
.dark-mode .badge-foundation { background: #4a148c; color: #ede7f6; }

.chapter-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.chapter-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
    font-size: 0.9rem;
}

.spec-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spec-item i {
    color: var(--accent-color);
    width: 20px;
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
    margin-top: 10px;
}

.chapter-updated {
    background-color: #fff8e7;
    color: #b45f06;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 30px;
    display: inline-block;
}

.dark-mode .chapter-updated {
    background-color: #3d2e1a;
    color: #ffb74d;
}

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--bg-primary);
    margin: 50px auto;
    padding: 30px;
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
}

.modal-close {
    position: absolute;
    right: 25px;
    top: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.modal-body {
    line-height: 1.8;
}

.modal-body h4 {
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal-body ul, .modal-body ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.modal-body th, .modal-body td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
}

.modal-body th {
    background-color: var(--bg-secondary);
}

.modal-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.btn-pdf {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-pdf:hover {
    background-color: #c82333;
}

.btn-close-modal {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

/* ===== CALCULATOR SECTION ===== */
.calculator-section {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 30px;
    margin: 40px 0;
    box-shadow: var(--card-shadow);
}

.calculator-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    flex-wrap: wrap;
}

.calc-tab {
    padding: 10px 25px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.calc-tab.active {
    background: var(--primary-color);
    color: white;
}

.calc-pane {
    display: none;
}

.calc-pane.active {
    display: block;
}

.calc-form {
    max-width: 500px;
}

.calc-row {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.calc-row label {
    font-weight: 500;
    color: var(--text-primary);
}

.calc-row input,
.calc-row select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

.calc-row small {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.btn-calc {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    margin-top: 10px;
}

.btn-calc:hover {
    background: #1e5f48;
    transform: translateY(-2px);
}

.calc-result {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}

.calc-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ===== COMPARISON TABLE ===== */
.comparison-section {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 30px;
    margin: 40px 0;
    box-shadow: var(--card-shadow);
}

.table-responsive {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    min-width: 1000px;
}

.comparison-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px;
    text-align: left;
}

.comparison-table td {
    padding: 10px;
    border: 1px solid var(--border-color);
}

.comparison-table tr:nth-child(even) {
    background: var(--bg-secondary);
}

.close-comparison {
    margin-top: 20px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ===== COMMENTS SECTION ===== */
.comments-section {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 30px;
    margin: 40px 0;
    box-shadow: var(--card-shadow);
}

.rating-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.average-rating {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rating-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.stars {
    display: flex;
    gap: 2px;
    color: #ffc107;
}

.star-rating {
    display: flex;
    gap: 5px;
    margin: 15px 0;
    font-size: 1.5rem;
}

.star-rating i {
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.star-rating i.active,
.star-rating i:hover {
    color: #ffc107;
}

.rating-form {
    margin-bottom: 30px;
}

.rating-form textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100px;
    margin: 15px 0;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.comment-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.comment-header {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
}

.comment-rating {
    color: #ffc107;
}

.comment-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== FOOTER ===== */
.site-footer {
    background: var(--primary-dark);
    color: white;
    padding: 60px 0 0;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-info h4,
.footer-links h4,
.footer-update h4 {
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--secondary-color);
    padding-left: 5px;
}

.footer-bottom {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
}

/* ===== BACK TO TOP ===== */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--secondary-color);
    color: var(--primary-dark);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: var(--transition);
    z-index: 98;
}

#backToTop:hover {
    transform: translateY(-3px);
    background: #ffc107;
}

/* ===== LOADING & NO RESULTS ===== */
.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.loading-spinner i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

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

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    background: var(--bg-primary);
    border-radius: 16px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media screen and (max-width: 992px) {
    .site-header .container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-controls {
        flex-direction: column;
    }
    
    .site-title {
        font-size: 1.8rem;
    }
    
    .chapters-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
    }
    
    .nav-menu.show {
        display: flex;
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 20px;
    }
    
    .calculator-tabs {
        flex-direction: column;
    }
    
    .calc-tab {
        width: 100%;
        text-align: center;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 480px) {
    .site-title {
        font-size: 1.5rem;
        flex-wrap: wrap;
    }
    
    .chapter-header {
        flex-direction: column;
        text-align: center;
    }
    
    .chapter-number {
        min-width: auto;
    }
    
    .quick-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .rating-summary {
        flex-direction: column;
        text-align: center;
    }
}