:root {
    --primary-color: #000000;
    --secondary-color: #555;
    --background-color: #ecf0f1;
    --text-color: #333;
    --card-background: #fff;
    --shadow-color: rgba(0, 0, 0, 0.08); /* Softer shadow */
    --skill-background: #e0e0e0;
    --border-color: #ddd;
    --hover-color: #333333;
}

html {
    scroll-behavior: smooth;
}

body.dark-mode {
    --primary-color: #ffffff;
    --secondary-color: #bbb;
    --background-color: #1c1c1c;
    --text-color: #f1f1f1;
    --card-background: #2d2d2d;
    --shadow-color: rgba(0, 0, 0, 0.3); /* Softer shadow for dark mode */
    --skill-background: #444;
    --border-color: #555;
    --hover-color: #dddddd;
}

body {
    font-family: 'Lato', sans-serif;
    line-height: 1.6; /* Adjusted for better readability */
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.5s, color 0.5s;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    background: var(--card-background);
    padding: 45px;
    border-radius: 20px;
    box-shadow: 0 15px 35px var(--shadow-color);
    transition: background-color 0.5s, box-shadow 0.5s;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Styles for the new theme toggle container */
#theme-toggle-container {
    position: relative; /* Needed for absolute positioning of icons */
    width: 30px; /* Adjust as needed */
    height: 30px; /* Adjust as needed */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

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

#theme-toggle-container .moon-icon,
#theme-toggle-container .sun-icon {
    font-size: 24px; /* Icon size */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the icon */
    transition: opacity 0.4s ease, transform 0.4s ease;
    color: var(--primary-color); /* Inherit primary color */
}

/* Initial state: moon visible, sun hidden */
#theme-toggle-container .moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
}

#theme-toggle-container .sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg); /* Start rotated for animation */
}

/* Dark mode state: sun visible, moon hidden */
body.dark-mode #theme-toggle-container .moon-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg); /* Rotate out */
}

body.dark-mode #theme-toggle-container .sun-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg); /* Rotate in */
}


/* Main header styles */
.main-header {
    display: flex;
    align-items: center;
    text-align: left;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 25px;
    margin-bottom: 45px;
}

.main-header img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin-right: 35px;
    border: 4px solid var(--primary-color);
    object-fit: cover;
    transition: transform 0.4s;
}

.main-header img:hover {
    transform: scale(1.05);
}

header h1 {
    margin: 0;
    color: var(--primary-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 3.2em;
    font-weight: 700;
}

header h2 {
    margin: 8px 0 18px;
    color: var(--secondary-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6em;
    font-weight: 400;
}

.contact-info {
    font-size: 1.1em;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.contact-info a, .contact-info span {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s;
    display: flex;
    align-items: center;
}

.contact-info a:hover {
    color: var(--hover-color);
    transform: translateY(-3px);
}

body.dark-mode .contact-info a:hover {
    color: var(--hover-color);
}

.contact-info i {
    margin-right: 10px;
    transition: transform 0.3s;
}

.contact-info a:hover i {
    transform: scale(1.2);
}

.section {
    margin-bottom: 45px;
}

.animated-item {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.animated-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.section h3 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
    color: var(--primary-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 2.3em;
    margin-bottom: 25px;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.section h3 i {
    margin-right: 15px;
    font-size: 0.9em;
    color: var(--primary-color);
}

.summary p {
    font-size: 1.1em;
    text-align: justify;
}

.experience-item {
    margin-bottom: 35px;
    padding: 25px;
    border-left: 5px solid var(--primary-color);
    position: relative;
    transition: transform 0.4s, box-shadow 0.4s, background-color 0.4s;
    border-radius: 8px;
}

.experience-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px var(--shadow-color);
    /* background-color: var(--skill-background); */ /* Removed grey highlight */
}

body.dark-mode .experience-item:hover {
    /* background-color: #3a3a3a; */ /* Removed grey highlight */
}

.experience-item::before {
    content: '\f5a0';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: -17px;
    top: 25px;
    font-size: 24px;
    color: var(--primary-color);
    background: var(--background-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
}

.job-title {
    font-weight: 700;
    font-size: 1.4em;
    color: var(--text-color);
}

.company-name {
    font-style: normal;
    font-weight: 500;
    color: var(--secondary-color);
    margin-bottom: 8px;
}

.duration {
    font-size: 0.95em;
    color: #888;
    margin-bottom: 18px;
    display: block;
}

.skills-category {
    margin-bottom: 25px;
    padding: 0.1px 15px 15px 15px; /* Modified to remove top padding */
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
}

.skills-category:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px var(--shadow-color);
    /* background-color: #d0d0d0; */ /* Removed grey highlight */
}

body.dark-mode .skills-category:hover {
    /* background-color: #3a3a3a; */ /* Removed grey highlight */
}

.skills-category h4 {
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 10px; /* Reduced from 15px */
    font-size: 1.2em;
    display: flex; /* Added to align icon and text */
    align-items: center; /* Added to align icon and text */
}

.skills-category h4 i {
    margin-right: 10px; /* Added margin to the icon */
    color: var(--primary-color); /* Ensure icon color matches primary */
}

.skills-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Reduced from 15px */
}

.skills-list li {
    background: var(--skill-background);
    padding: 8px 15px; /* Reduced from 10px 20px */
    border-radius: 25px;
    font-size: 1.05em;
    font-weight: 500;
    transition: background-color 0.4s, color 0.4s, transform 0.3s;

    /* New styles for skill level and rating */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* For absolute positioning of the level text */
}

.skills-list li:hover:not(.no-hover) {
    background-color: var(--primary-color);
    color: #fff;
    transform: translateY(-3px) scale(1.05);
}

body.dark-mode .skills-list li:hover:not(.no-hover) {
    color: #000;
}

/* Style for the skill rating bar */
.skills-list li .skill-rating {
    width: 100px; /* Total width for 5 segments */
    height: 10px;
    background-color: #ccc; /* Color for empty segments */
    border-radius: 5px;
    overflow: hidden;
    margin-left: 10px; /* Space from skill name */
    flex-shrink: 0; /* Prevent rating bar from shrinking */
    position: relative; /* For potential future enhancements */
}

.skills-list li .skill-rating::before {
    content: '';
    display: block;
    height: 100%;
    background-color: var(--primary-color); /* Color for filled segments */
    border-radius: 5px;
    transition: width 0.5s ease-in-out;
}

/* Set width of the filled rating bar based on data-rating */
.skills-list li[data-rating="1"] .skill-rating::before { width: 20%; }
.skills-list li[data-rating="2"] .skill-rating::before { width: 40%; }
.skills-list li[data-rating="3"] .skill-rating::before { width: 60%; }
.skills-list li[data-rating="4"] .skill-rating::before { width: 80%; }
.skills-list li[data-rating="5"] .skill-rating::before { width: 100%; }

ul.job-details {
    list-style: disc;
    margin-top: 12px;
    padding-left: 28px;
}

ul.job-details li {
    margin-bottom: 10px;
}

.education-item {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
}

.education-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px var(--shadow-color);
    /* background-color: var(--skill-background); */ /* Removed grey highlight */
}

body.dark-mode .education-item:hover {
    /* background-color: #3a3a3a; */ /* Removed grey highlight */
}

#back-to-top {
    position: fixed;
    bottom: 35px;
    right: 35px;
    display: none;
    width: 55px;
    height: 55px;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    line-height: 55px;
    font-size: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.4s, background-color 0.4s, transform 0.3s;
    z-index: 1000;
}

body.dark-mode #back-to-top {
    color: #000;
}

#back-to-top:hover {
    background-color: var(--hover-color);
    transform: scale(1.1);
}

/* --- Responsive Design --- */
@media (max-width: 1200px) {
    .container {
        margin: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    .container {
        padding: 30px;
        margin: 0;
        border-radius: 0;
    }
    .main-header {
        flex-direction: column;
        text-align: center;
    }
    .main-header img {
        margin-right: 0;
        margin-bottom: 20px; /* Adjusted margin */
    }
    header h1 {
        font-size: 2.8em; /* Adjusted font size */
    }
    header h2 {
        font-size: 1.4em; /* Adjusted font size */
    }
    .section h3 {
        font-size: 2em; /* Adjusted font size */
    }
    .contact-info {
        /* Use CSS Grid for a perfect 2x2 layout */
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* Create a 2-column grid */
        gap: 15px;
    }
    .summary p {
        font-size: 1em; /* Adjusted font size */
    }
    .job-title {
        font-size: 1.3em; /* Adjusted font size */
    }
    .skills-list {
        justify-content: flex-start; /* Changed from center to flex-start */
    }
    .skills-list li {
        font-size: 1em; /* Adjusted font size */
    }

    /* Disable hover effects on small screens */
    .skills-list li:hover:not(.no-hover) {
        background-color: var(--skill-background); /* Revert to default background */
        color: var(--text-color); /* Revert to default text color */
        transform: none; /* Remove any transform */
    }

    .skills-category:hover {
        transform: none; /* Remove any transform */
        box-shadow: 0 5px 15px var(--shadow-color); /* Revert to default shadow */
        background-color: var(--card-background); /* Revert to default background */
    }

    .experience-item:hover {
        transform: none; /* Remove any transform */
        box-shadow: none; /* Remove any shadow */
        background-color: transparent; /* Revert to default background */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px; /* Adjusted padding */
    }
    header h1 {
        font-size: 2.2em; /* Adjusted font size */
    }
    header h2 {
        font-size: 1.2em; /* Adjusted font size */
    }
    .contact-info {
        font-size: 0.9em; /* Adjusted font size */
        /* Grid layout is inherited from the 768px breakpoint */
    }
    .section h3 {
        font-size: 1.8em; /* Adjusted font size */
    }
    .summary p {
        font-size: 0.95em; /* Adjusted font size */
    }
    .job-title {
        font-size: 1.2em; /* Adjusted font size */
    }
    .skills-list li {
        font-size: 0.9em; /* Adjusted font size */
        padding: 8px 15px; /* Adjusted padding */
    }
    #back-to-top {
        width: 45px;
        height: 45px;
        line-height: 45px;
        font-size: 24px;
        bottom: 25px;
        right: 25px;
    }
}