:root {
    --primary-color: #2563eb;
    --secondary-color: #3b82f6;
    --background-color: #f8fafc;
    --text-color: #1e293b;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-width: 320px; /* Minimum width for very small devices */
}

header {
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 2rem;
    position: relative;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

nav {
    display: flex;
    gap: 2rem;
}

/* Navigation dropdown styles */
.nav-item {
    position: relative;
}

.dropdown-toggle::after {
    content: " ▼";
    font-size: 0.7rem;
    margin-left: 0.3rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
    min-width: 180px;
    z-index: 1000;
}

.dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 400;
    border-radius: 0;
    transition: background-color 0.2s;
}

.dropdown-menu a:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.nav-item:hover .dropdown-menu {
    display: block;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 5px;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
    transition: var(--transition);
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

nav a:hover {
    background-color: var(--primary-color);
    color: white;
}

main {
    margin-top: 6rem;
    padding: 1rem; /* Reduced padding for better mobile experience */
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%; /* Ensure it takes full width */
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.display-mode-selector {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    min-width: 120px;
    flex-grow: 1; /* Allow it to grow */
    max-width: 200px; /* But not too much */
}

#text-to-sign-form button {
    flex: 1;
    min-width: 180px; /* Ensure button is not too small */
}

.content-section {
    padding: 1.5rem; /* Reduced padding for mobile */
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(255, 255, 255, 1);
    margin-bottom: 2rem;
    width: 100%; /* Ensure it takes full width */
}

.content-section h2 {
    color: var(--primary-color);
    font-size: clamp(1.5rem, 5vw, 2rem); /* Responsive font size */
    margin-bottom: 1rem;
    text-align: center;
    word-break: break-word; /* Prevent overflow on small devices */
}

.content-section p {
    color: #ffffffff;
    text-align: center;
    max-width: 600px;
    margin: 0 auto 2rem;
    font-size: clamp(0.9rem, 4vw, 1rem); /* Responsive font size */
}

.warning {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: #fee2e2;
    color: #991b1b;
    border-radius: var(--border-radius);
    font-weight: 500;
    margin: 1rem auto;
    display: block;
    width: fit-content;
    max-width: 100%; /* Ensure it doesn't overflow */
    box-sizing: border-box;
    text-align: center; /* Center text */
    font-size: clamp(0.85rem, 4vw, 0.95rem); /* Responsive font size */
}

/* Mode Selector Styles */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.mode-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    background-color: #e2e8f0;
    transition: var(--transition);
}

.mode-selector label:hover {
    background-color: #cbd5e1;
}

.mode-selector input[type="radio"] {
    margin-right: 0.5rem;
}

.mode-selector input[type="radio"]:checked + label {
    background-color: var(--primary-color);
    color: white;
}

/* Video Controls Panel */
.video-controls-panel {
    background-color: #e2e8f0;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%; /* Full width */
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap; /* Allow wrapping */
}

.control-group label {
    font-weight: 500;
    min-width: 90px; /* Ensure label has enough space */
}

.control-group select {
    padding: 0.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #cbd5e1;
    background-color: white;
    font-family: 'Inter', sans-serif;
    flex-grow: 1;
    max-width: 200px;
}

.control-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    min-width: 100px; /* Ensure button is large enough for touch */
}

.control-btn:hover {
    background-color: var(--secondary-color);
}

/* Video container styles */
.video-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%; /* Full width */
}

.video-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* Allow wrapping */
    justify-content: center;
}

.video-btn {
    width: 44px; /* Larger for touch targets */
    height: 44px; /* Larger for touch targets */
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.video-btn:hover {
    background-color: var(--secondary-color);
}

#text-to-sign-form {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

textarea {
    width: 100%;
    height: 120px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
    transition: var(--transition);
    box-sizing: border-box;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: var (--transition);
    display: block;
    margin: 0 auto;
    min-height: 44px; /* Minimum height for touch targets */
}

button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

#translated-images {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding: 1rem;
    width: 100%;
}

#translated-videos {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding: 1rem;
    width: 100%;
}

.sign-container {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    text-align: center;
    min-height: 170px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: calc(33.33% - 1rem); /* 3 per row by default */
    max-width: 150px; /* Maximum width */
}

.sign-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sign-container img {
    border-radius: 8px;
    margin-bottom: 0.5rem;
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    width: auto;
    height: auto;
}

.sign-container video {
    border-radius: 8px;
    margin-bottom: 0.5rem;
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    width: auto;
    height: auto;
}

.video-player {
    width: 120px;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.video-controls-wrapper {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
}

.individual-control {
    width: 36px; /* Larger for touch targets */
    height: 36px; /* Larger for touch targets */
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sign-container p {
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
    font-size: 1rem;
}

footer {
    padding: 2rem;
    text-align: center;
    margin-top: 4rem;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
}

footer p {
    color: #64748b;
    font-size: clamp(0.9rem, 4vw, 1rem);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Combined Video Player Styles */
.combined-video-player {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 2rem;
    border-radius: var(--border-radius);
    padding: 1.5rem; /* Reduced padding for mobile */
    box-shadow: 0 4px 6px rgba(255, 255, 255, 1);
}rgba(255, 255, 255, 0.1)rgba(255, 255, 255, 1)

.combined-video-player h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: clamp(1.2rem, 5vw, 1.6rem); /* Responsive font size */
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.75rem;
    word-break: break-word; /* Prevent overflow on small devices */
}

.combined-player {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.video-and-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.combined-player video {
    width: 100%;
    max-width: 400px;
    border-radius: var(--border-radius);
    background-color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.current-letter-display {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-align: center;
    font-size: clamp(1rem, 4vw, 1.3rem); /* Responsive font size */
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

/* Progress tracking */
.progress-section {
    width: 100%;
    margin: 1.5rem 0;
}

.progress-container {
    width: 100%;
    height: 16px;
    background-color: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: clamp(0.85rem, 4vw, 1rem); /* Responsive font size */
    color: #4b5563;
    font-weight: 500;
}

/* Controls section */
.controls-section {
    background-color: #f1f5f9;
    border-radius: var(--border-radius);
    padding: 1.2rem;
    margin-top: 0.5rem;
    width: 100%;
}

.combined-video-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.primary-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* Allow buttons to wrap */
    justify-content: center;
}

.control-btn {
    min-width: 100px; /* Reduced from 120px for better mobile fit */
    min-height: 44px; /* Ensure minimum height for touch targets */
    padding: 0.8rem 1.2rem; /* Slightly reduced padding */
    border-radius: var(--border-radius);
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    font-size: clamp(0.9rem, 4vw, 1.1rem); /* Responsive font size */
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1; /* Allow flex growing for equal widths */
    max-width: 150px; /* Maximum width */
}

.control-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.control-btn.play-btn {
    background-color: #10b981;
}

.control-btn.play-btn:hover {
    background-color: #059669;
}

.control-btn.pause-btn {
    background-color: #f59e0b;
}

.control-btn.pause-btn:hover {
    background-color: #d97706;
}

.control-btn.restart-btn {
    background-color: #6366f1;
}

.control-btn.restart-btn:hover {
    background-color: #4f46e5;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap; /* Allow wrapping on very small screens */
    justify-content: center;
    width: 100%;
    max-width: 300px;
}

.speed-control label {
    font-weight: 500;
    color: var(--text-color);
    min-width: 110px; /* Minimum width for label */
    font-size: clamp(0.85rem, 4vw, 1rem); /* Responsive font */
}

.speed-control select {
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid #cbd5e1;
    background-color: white;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    color: var(--text-color);
    flex-grow: 1; /* Allow growing */
    min-width: 100px; /* Minimum width */
    max-width: 180px; /* Maximum width */
}

/* Letter sequence visualization */
.letter-sequence {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem; /* Slightly reduced gap for mobile */
    margin-top: 1.5rem;
    padding: 1.2rem;
    background-color: #f8fafc;
    border-radius: var(--border-radius);
    border: 1px solid #e2e8f0;
    width: 100%;
}

.letter-sequence h4 {
    width: 100%;
    text-align: center;
    margin-bottom: 0.75rem;
    font-size: clamp(1rem, 4vw, 1.2rem); /* Responsive font size */
    color: var(--text-color);
}

.sequence-letter {
    display: inline-flex;
    width: clamp(30px, 10vw, 45px); /* Responsive width */
    height: clamp(30px, 10vw, 45px); /* Responsive height */
    align-items: center;
    justify-content: center;
    background-color: #e2e8f0;
    border-radius: 8px;
    font-weight: 600;
    font-size: clamp(1rem, 4vw, 1.2rem); /* Responsive font size */
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.sequence-letter.active {
    background-color: var(--primary-color);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sequence-letter.completed {
    background-color: #a3e635;
    color: #365314;
}

.sequence-letter.non-letter {
    background-color: transparent;
    border: 1px dashed #cbd5e1;
    box-shadow: none;
}

/* Tips section */
.sign-language-tips {
    margin-top: 2rem;
    background-color: #eff6ff;
    border-left: 5px solid var(--primary-color);
    padding: 1.2rem;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.sign-language-tips h4 {
    font-size: clamp(1rem, 4vw, 1.2rem); /* Responsive font size */
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.sign-language-tips p {
    font-size: clamp(0.9rem, 4vw, 1.05rem); /* Responsive font size */
    color: #374151;
    margin: 0;
    line-height: 1.6;
}

/* Character Counter Styles */
.input-container {
    position: relative;
    margin-bottom: 1.5rem;
    width: 100%;
}

.char-indicator {
    position: absolute;
    bottom: -22px;
    right: 0;
    font-size: clamp(0.75rem, 3vw, 0.85rem); /* Responsive font size */
    color: #64748b;
}

.char-limit-exceeded {
    color: #ef4444;
}

textarea.invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Image grid for sign images */
.sign-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    width: 100%;
    justify-content: center;
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .combined-player {
        grid-template-columns: 1fr 1fr;
    }
    
    .video-and-display {
        grid-column: 1;
    }
    
    .controls-section {
        grid-column: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .progress-section {
        grid-column: span 2;
    }
    
    .letter-sequence {
        grid-column: span 2;
    }
    
    .sign-language-tips {
        grid-column: span 2;
    }

    main {
        padding: 2rem;
    }
    
    .content-section {
        padding: 2rem;
    }
}

@media (max-width: 767px) {
    .combined-video-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .primary-controls {
        width: 100%;
        justify-content: center;
    }
    
    .speed-control {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 1rem; /* Reduced side padding */
    }

    .menu-toggle {
        display: flex;
        order: 2;
    }

    nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        width: 200px;
        background-color: white;
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        gap: 0.5rem;
        border-radius: 0 0 var(--border-radius) var(--border-radius);
        z-index: 1000; /* Ensure dropdown is above other content */
    }

    nav.active {
        display: flex;
    }

    nav a {
        width: 100%;
        text-align: left;
        padding: 0.75rem 1rem;
    }
    
    .sign-container {
        width: calc(50% - 0.5rem); /* 2 per row on mobile */
        min-width: 100px;
    }
    
    .combined-video-player {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .sign-container {
        width: 100%; /* 1 per row on very small screens */
    }
    
    .header-content {
        padding: 0.5rem;
    }
    
    main {
        padding: 1rem 0.5rem;
    }
    
    .content-section {
        padding: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    #text-to-sign-form button,
    .display-mode-selector {
        width: 100%;
        max-width: none;
    }
    
    .warning {
        padding: 0.5rem 1rem;
    }
}
