/* --- CSS Variables for Theming --- */
:root {
    --bg-color: #f4f7f9;
    --content-bg: #ffffff;
    --text-color: #333333;
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --border-color: #e0e0e0;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --font-heading: 'Poppins', sans-serif;

    /* --- NEW: Password Generator Specific Colors --- */
    --password-primary-color: #11998e;
    --password-secondary-color: #38ef7d;
}

body.dark-theme {
    --bg-color: #1a1a1a;
    --content-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --primary-color: #818cf8;
    --secondary-color: #a78bfa;
    --border-color: #444444;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* --- NEW: Dark Mode Password Colors --- */
    --password-primary-color: #0f766e;
    --password-secondary-color: #10b981;
}

/* --- Global Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px 5%;
}

main {
    background-color: var(--content-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    transition: background-color 0.3s ease;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    margin-bottom: 2rem;
}

/* --- Header & Theme Toggle --- */
header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --- NEW: Center the title --- */
.header-title-wrapper {
    text-align: center;
    flex-grow: 1;
}

header h1 {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* --- UPDATED: Style the theme toggle wrapper and label --- */
.theme-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between label and toggle */
    font-family: var(--font-heading);
    font-weight: 600;
}

.theme-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-toggle input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "🌞";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

input:checked + .slider {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

input:checked + .slider:before {
    transform: translateX(26px);
    content: "🌙";
}

/* --- Tab Navigation --- */
.tab-nav {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-color);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover:not(.active) {
    color: var(--secondary-color);
}

/* --- Tab Content --- */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Shared Component Styles --- */
textarea, input[type="text"] {
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--content-bg);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    font-family: var(--font-heading);
}

/* --- Buttons --- */
.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.btn:active {
    transform: translateY(0);
}

/* --- NEW: Click Effect Class --- */
.btn-clicked {
    transform: scale(0.96);
    transition: transform 0.1s;
}

/* --- UPDATED: Password Generator Specific Colors --- */
#generator .btn {
    background: linear-gradient(135deg, var(--password-primary-color), var(--password-secondary-color));
}

#generator .btn:hover {
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.4);
}

#generator textarea:focus, #generator input[type="text"]:focus {
    border-color: var(--password-primary-color);
    box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.2);
}

/* --- Action Buttons --- */
.btn-action {
    background-color: #2ecc71;
}

.btn-action:hover {
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.3);
}

#clear-text-btn, #regenerate-password-btn {
    background-color: #3498db;
}

#clear-text-btn:hover, #regenerate-password-btn:hover {
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

/* --- Text Converter Specific --- */
.converter-container, .generator-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.buttons-grid, .action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

/* --- Password Generator Specific --- */
.password-output-wrapper {
    display: flex;
    gap: 10px;
}

.password-output-wrapper input {
    flex-grow: 1;
}

.password-strength {
    margin-top: 10px;
    font-size: 0.9rem;
}

.strength-bar {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    margin: 5px 0;
    overflow: hidden;
}

#strength-bar-fill {
    height: 100%;
    width: 0%;
    background-color: #e74c3c;
    transition: width 0.3s, background-color 0.3s;
}

.password-options .option-group {
    margin-bottom: 1rem;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.password-options .checkboxes label {
    display: block;
    font-weight: 400;
    cursor: pointer;
    margin-bottom: 8px;
}

.password-options .checkboxes input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: middle;
}

/* --- Toast Notification --- */
#toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    font-family: var(--font-heading);
    opacity: 0;
    transition: opacity 0.5s, visibility 0.5s;
}

#toast.show {
    visibility: visible;
    opacity: 1;
}

/* --- Footer --- */
footer {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.7;
    padding: 1rem 0;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    body {
        padding: 10px 2.5%;
    }
    main {
        padding: 1.5rem;
    }
    header h1 {
        font-size: 2rem;
    }
}

@media (min-width: 992px) {
    .converter-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "input output"
            "buttons buttons"
            "actions actions";
    }
    .input-area { grid-area: input; }
    .output-area { grid-area: output; }
    .buttons-grid { grid-area: buttons; }
    .action-buttons { grid-area: actions; }
    
    .action-buttons {
        grid-template-columns: 1fr 1fr;
    }
}