/* Portfolio - Clean CSS Architecture */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Color System */
:root {
    --primary: #2563eb;
    --text: #1f2937;
    --bg: #fff;
    --bg-alt: #f9fafb;
    --border: #e5e7eb;
    --gap: 1rem;
    --section-pad: 4rem;
}

body.dark-mode {
    --text: #f3f4f6;
    --bg: #111827;
    --bg-alt: #1f2937;
    --border: #374151;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 var(--gap);
}

/* Navigation */
.navbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.3s;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    animation: slideIn 0.3s;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Sections */
section {
    padding: var(--section-pad) var(--gap);
}

.hero {
    text-align: center;
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.tagline {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.skills-brief {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

body.dark-mode .skills-brief {
    color: #9ca3af;
}

.bio {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

body.dark-mode .bio {
    color: #d1d5db;
}

.cta-buttons {
    display: flex;
    gap: var(--gap);
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

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

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

.btn-secondary {
    background: var(--bg-alt);
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

/* About */
.about {
    background: var(--bg);
    padding: var(--section-pad) var(--gap);
}

.about h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-weight: 700;
}

.about p {
    font-size: 1rem;
    line-height: 1.8;
    color: #6b7280;
    max-width: 700px;
}

body.dark-mode .about h2 {
    color: #ffffff;
}

body.dark-mode .about p {
    color: #d1d5db;
}

/* Projects */
.projects {
    background: var(--bg-alt);
}

.projects h2,
.skills h2,
.education h2,
.contact h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text);
    font-weight: 700;
}

/* Dark mode overrides h2 - higher specificity */
body.dark-mode .projects h2,
body.dark-mode .skills h2,
body.dark-mode .education h2,
body.dark-mode .contact h2 {
    color: #ffffff;
}

body.dark-mode .contact h2 {
    color: #fff;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    transition: transform 0.3s, box-shadow 0.3s;
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

.project-card:nth-child(1) { animation-delay: 0.1s; }
.project-card:nth-child(2) { animation-delay: 0.2s; }
.project-card:nth-child(3) { animation-delay: 0.3s; }

.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

.project-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.description,
.tech-stack,
.metrics {
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

body.dark-mode .description,
body.dark-mode .tech-stack,
body.dark-mode .metrics {
    color: #d1d5db;
}

.project-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    margin-top: var(--gap);
    transition: color 0.3s;
}

.project-link:hover {
    color: #1e40af;
}

/* Skills */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.skill-group h3 {
    font-size: 1.1rem;
    margin-bottom: var(--gap);
    color: var(--primary);
}

.skill-group ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skill-group li {
    padding: 4px 10px;
    color: var(--text);
    background: var(--bg-alt);
    border: 2px solid var(--primary);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
}

.skill-group li:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

/* Education */
.education-item {
    background: var(--bg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    margin-bottom: 2rem;
}

.education-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.school {
    font-weight: 600;
    color: var(--primary);
}

.year {
    color: #9ca3af;
    font-size: 0.9rem;
}

.details {
    color: #6b7280;
    margin-top: 0.5rem;
}

body.dark-mode .year,
body.dark-mode .details {
    color: #d1d5db;
}

/* Contact */
.contact {
    background: var(--bg);
    text-align: center;
}

.contact h2 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 3rem;
}

.social-links {
    display: flex;
    gap: var(--gap);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.social-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.social-btn:hover {
    background: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Education & Certificates */
.education {
    background: var(--bg-alt);
}

.education-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .education-grid {
        grid-template-columns: 1fr;
    }
}

.cert-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.cert-image {
    max-width: 100%;
    width: 420px;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

@media (max-width: 768px) {
    .cert-image {
        width: 200px;
    }
}

body.dark-mode .cert-image {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cert-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

/* Certificate Modal */
.cert-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

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

.cert-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
}

.cert-modal-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 0.5rem;
}

.cert-modal-close {
    position: absolute;
    top: -30px;
    right: 0;
    font-size: 32px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: color 0.3s;
}

.cert-modal-close:hover {
    color: #ccc;
}

.cert-verify-btn {
    display: inline-block;
    width: fit-content;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
}

.cert-verify-btn:hover {
    background: #1e40af;
    transform: translateX(4px);
}

/* Footer */
.footer {
    background: var(--text);
    color: #fff;
    text-align: center;
    padding: 2rem var(--gap);
    margin-top: 2rem;
}

body.dark-mode .footer {
    background: #0f172a;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from { width: 0; }
    to { width: 100%; }
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --section-pad: 2rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .nav-links {
        gap: var(--gap);
        font-size: 0.9rem;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .contact h2 {
        font-size: 1.75rem;
    }

    .social-links {
        flex-direction: column;
    }

    .social-btn {
        width: 100%;
    }

    .chat-container {
        max-height: 400px;
    }

    .chat-input-box {
        flex-direction: column;
    }

    .chat-input {
        border-radius: 8px 8px 0 0;
    }

    .chat-send-btn {
        border-radius: 0 0 8px 8px;
    }
}

/* Chatbot Section */
.chat-section {
    padding: var(--section-pad) 0;
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
}

.chat-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.chat-subtitle {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1rem;
}

body.dark-mode .chat-subtitle {
    color: #d1d5db;
}

.chat-wrapper {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 600px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

body.dark-mode .chat-wrapper {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    animation: messageSlide 0.3s ease-out;
}

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

.message-user {
    justify-content: flex-end;
}

.message-assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 0.875rem 1.125rem;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-user .message-bubble {
    background: var(--primary);
    color: #fff;
    border-radius: 12px 4px 12px 12px;
}

.message-assistant .message-bubble {
    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px 12px 12px 12px;
}

.message-bubble p {
    margin: 0;
    font-size: 0.95rem;
}

.chat-footer {
    border-top: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-input-form {
    display: flex;
    gap: 0.5rem;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-input.at-limit {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.char-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 600;
    pointer-events: none;
}

.chat-input.at-limit ~ .char-counter {
    color: #ef4444;
}

body.dark-mode .char-counter {
    color: #6b7280;
}

body.dark-mode .chat-input.at-limit ~ .char-counter {
    color: #fca5a5;
}

.send-btn {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.send-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.send-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.send-btn.loading .send-icon {
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

.send-icon {
    font-size: 1.25rem;
}

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

.rate-limit-warning {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 6px;
    color: #dc2626;
    font-size: 0.9rem;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

body.dark-mode .rate-limit-warning {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fecaca;
}

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

@media (max-width: 768px) {
    .chat-wrapper {
        max-height: 500px;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    .chat-section h2 {
        font-size: 1.5rem;
    }

    .chat-subtitle {
        font-size: 0.95rem;
    }

    .send-btn {
        padding: 0.75rem 1rem;
    }
}


