:root {
    --primary-color: #5e91d0;
    --secondary-color: #264573;
    --text-color: #000222;
    --light-bg: #f8f9fa;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --primary-light: #8fb3db;
    --primary-dark: #4a7ab8;
    --shadow-sm: 0 2px 4px rgba(38, 69, 115, 0.1);
    --shadow-md: 0 4px 12px rgba(38, 69, 115, 0.15);
    --shadow-lg: 0 8px 24px rgba(38, 69, 115, 0.2);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    background: #ffffff;
    position: relative;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.03) 0%, 
        rgba(38, 69, 115, 0.05) 50%,
        rgba(94, 145, 208, 0.02) 100%);
    z-index: -2;
}

.decorative-shape {
    position: fixed;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-light));
    opacity: 0.05;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: 10%;
    left: -150px;
    animation: drift 25s infinite ease-in-out;
}

.shape-2 {
    width: 200px;
    height: 200px;
    bottom: 10%;
    right: -100px;
    animation: drift 30s infinite ease-in-out reverse;
}

@keyframes drift {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(30px) rotate(180deg); }
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
}

h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: clamp(1rem, 2.5vw, 1.2rem); }

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(94, 145, 208, 0.1);
}

header .container {
    padding: 0.5rem 1.5rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.logo {
    height: clamp(40px, 8vw, 60px);
    width: auto;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.header-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.header-nav a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    font-size: 0.95rem;
}

.header-nav a:hover {
    color: var(--primary-color);
}

.main-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.main-header p {
    color: #666;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    max-width: 600px;
    margin: 0 auto;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex: 1;
    align-items: start;
}

.card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid rgba(94, 145, 208, 0.1);
    transition: all 0.3s ease;
    height: fit-content;
}

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

.password-card {
    position: relative;
    overflow: hidden;
}

.password-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    animation: gradient-shift 3s ease infinite;
}

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

.password-display {
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.05) 0%, 
        rgba(38, 69, 115, 0.02) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 1.25rem;
    margin: 1rem 0 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    transition: all 0.3s ease;
}

.password-display:hover {
    border-color: var(--secondary-color);
    transform: translateY(-1px);
}

#generatedPassword {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--secondary-color);
    font-weight: bold;
    letter-spacing: 1px;
    word-break: break-all;
    margin-right: 1rem;
}

.password-actions {
    display: flex;
    gap: 0.5rem;
}

.copy-btn, .refresh-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    font-size: 0.9rem;
}

.refresh-btn {
    padding: 0.6rem 0.8rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-dark));
}

.copy-btn:hover, .refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.refresh-btn:hover svg {
    animation: rotate 0.5s ease;
}

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

.copy-btn.copied {
    background: linear-gradient(135deg, var(--success), #229a3e);
}

.copy-text {
    display: inline;
}

.password-info {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(94, 145, 208, 0.05);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.char-count, .password-entropy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.char-count strong, .password-entropy strong {
    color: var(--primary-color);
    font-size: 1rem;
}

.generate-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: clamp(1rem, 2vw, 1.1rem);
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(94, 145, 208, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(94, 145, 208, 0.4);
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.quick-btn {
    flex: 1;
    min-width: 50px;
    padding: 0.6rem 1rem;
    background: white;
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.quick-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.strength-meter {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.05) 0%, 
        rgba(38, 69, 115, 0.02) 100%);
    border-radius: 8px;
}

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

.strength-label {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.strength-bar {
    height: 10px;
    background: linear-gradient(90deg, #f0f0f0, #e0e0e0);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.strength-fill {
    height: 100%;
    transition: all 0.5s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.settings-card h2 {
    margin-bottom: 1.5rem;
}

.control-group {
    margin-bottom: 1.5rem;
}

.length-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.length-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.1) 0%, 
        rgba(38, 69, 115, 0.05) 100%);
    border-radius: 6px;
    min-width: 50px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(90deg, 
        var(--primary-light) 0%, 
        var(--primary-color) var(--range-progress, 50%), 
        #e0e0e0 var(--range-progress, 50%));
    outline: none;
    -webkit-appearance: none;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 2px solid white;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--secondary-color);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 2px solid white;
}

.length-markers {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

.checkbox-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.05) 0%, 
        rgba(255, 255, 255, 0.9) 100%);
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.checkbox-group:hover {
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.1) 0%, 
        rgba(255, 255, 255, 0.9) 100%);
    border-color: rgba(94, 145, 208, 0.2);
    transform: translateX(2px);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.checkbox-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-light);
    color: white;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
}

.info-card-mobile {
    display: none;
}

/* Sezioni Info e CTA */
.info-section {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(94, 145, 208, 0.1);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.info-card {
    padding: 1.25rem;
    background: linear-gradient(135deg, 
        rgba(94, 145, 208, 0.05) 0%, 
        rgba(255, 255, 255, 0.9) 100%);
    border-radius: 10px;
    border-left: 3px solid var(--primary-color);
    transition: all 0.3s ease;
}

.info-card:hover {
    transform: translateX(3px);
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.info-card p {
    font-size: 0.9rem;
    line-height: 1.5;
}

.cta-section {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px;
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.cta-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.25rem;
    background: rgba(255, 255, 255, 0.95);
    color: var(--secondary-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.cta-btn:hover {
    transform: translateY(-2px);
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

footer {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

footer p {
    margin: 0.3rem 0;
    font-size: 0.85rem;
    opacity: 0.95;
}

/* Animazioni */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* RESPONSIVE DESIGN */

/* Tablet Landscape e Small Desktop */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 1rem;
    }
    
    .main-layout {
        gap: 1rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .header-nav {
        display: none;
    }
}

/* Tablet Portrait */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .info-card-mobile {
        display: block;
        margin-top: 1rem;
    }
    
    .info-card-mobile ul {
        list-style: none;
        padding: 0;
    }
    
    .info-card-mobile li {
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(94, 145, 208, 0.1);
        font-size: 0.9rem;
    }
    
    .info-card-mobile li:last-child {
        border-bottom: none;
    }
    
    .main-header {
        margin-bottom: 1.5rem;
    }
    
    .copy-text {
        display: none;
    }
    
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .cta-buttons {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Large */
@media (max-width: 425px) {
    html {
        font-size: 15px;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    .card {
        padding: 1rem;
        border-radius: 10px;
    }
    
    .password-display {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    #generatedPassword {
        margin-right: 0;
        text-align: center;
    }
    
    .copy-btn {
        width: 100%;
        justify-content: center;
    }
    
    .generate-btn {
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }
    
    .checkbox-group {
        padding: 0.75rem;
    }
    
    .checkbox-icon {
        width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }
    
    .length-markers {
        font-size: 0.7rem;
    }
}

/* Mobile Small */
@media (max-width: 320px) {
    html {
        font-size: 14px;
    }
    
    .logo {
        height: 35px;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .checkbox-group label {
        font-size: 0.85rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --light-bg: #1a1a1a;
    }
}

/* Landscape Mode per Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        position: relative;
    }
    
    .main-header {
        margin-bottom: 1rem;
    }
    
    .main-header h1 {
        font-size: 1.3rem;
    }
    
    .main-header p {
        display: none;
    }
    
    .card {
        padding: 0.75rem;
    }
    
    .generate-btn {
        padding: 0.75rem;
        margin: 1rem 0;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    header, footer, .cta-section, .info-section {
        display: none;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* Accessibilità - Motion Reduce */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* iOS Specific */
@supports (-webkit-touch-callout: none) {
    input[type="range"] {
        -webkit-tap-highlight-color: transparent;
    }
    
    .generate-btn, .copy-btn, .quick-btn {
        -webkit-tap-highlight-color: rgba(94, 145, 208, 0.2);
    }
    
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Notch Support (iPhone X+) */
@supports (padding: max(0px)) {
    header {
        padding-top: max(0.75rem, env(safe-area-inset-top));
    }
    
    footer {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}
