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

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Language Selector */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 5px;
}

.language-selector select {
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #4f46e5;
    cursor: pointer;
    outline: none;
    border-radius: 6px;
    min-width: 120px;
}

.language-selector select:hover {
    background: #f8fafc;
}

/* RTL Support */
[dir="rtl"] .language-selector {
    right: auto;
    left: 20px;
}

[dir="rtl"] .top-mode-buttons {
    direction: rtl;
}

[dir="rtl"] .name-input-container {
    direction: rtl;
}

[dir="rtl"] .canvas-actions {
    direction: rtl;
}

[dir="rtl"] .download-buttons {
    direction: rtl;
}

/* Language-specific font adjustments */
[lang="zh"] {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

[lang="hi"] {
    font-family: 'Noto Sans Devanagari', 'Mangal', sans-serif;
}

[lang="ar"] {
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
}

[lang="en"], [lang="fr"], [lang="es"] {
    font-family: 'Inter', 'Roboto', sans-serif;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    text-align: center;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    color: #4f46e5;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.1rem;
    color: #6b7280;
}

/* Top Mode Selector */
.top-mode-selector {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
}

.top-mode-selector h2 {
    color: #374151;
    margin-bottom: 25px;
    font-size: 1.8rem;
    font-weight: 600;
}

.top-mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
}

.top-mode-btn {
    flex: 1;
    padding: 25px 20px;
    border: 3px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.top-mode-btn i {
    font-size: 2rem;
    color: #6b7280;
    margin-bottom: 5px;
}

.top-mode-btn span {
    font-weight: 600;
    font-size: 1.1rem;
    color: #374151;
}

.top-mode-btn small {
    color: #6b7280;
    font-size: 0.9rem;
}

.top-mode-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3);
}

.top-mode-btn.active i,
.top-mode-btn.active span,
.top-mode-btn.active small {
    color: white;
}

.top-mode-btn:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

/* Name Input Section */
.name-input-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
}

.name-input-section h3 {
    color: #374151;
    margin-bottom: 25px;
    font-size: 1.5rem;
    font-weight: 600;
}

.name-input-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.name-input-container input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.name-input-container input:focus {
    outline: none;
    border-color: #4f46e5;
}

.generate-btn {
    padding: 15px 25px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.generate-btn:hover {
    background: #3730a3;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(79, 70, 229, 0.3);
}

.generate-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* PDF Upload Section */
.pdf-upload-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

/* PDF Tab Selector */
.pdf-tab-selector {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    justify-content: center;
}

.pdf-tab-btn {
    flex: 1;
    max-width: 200px;
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pdf-tab-btn.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.pdf-tab-btn:hover {
    border-color: #4f46e5;
    background: #f0f9ff;
}

.pdf-tab-btn.active:hover {
    background: #3730a3;
}

/* PDF Sections */
.pdf-section {
    background: #f9fafb;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.pdf-drawing-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.save-drawing-btn,
.download-drawing-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-drawing-btn {
    background: #10b981;
    color: white;
}

.save-drawing-btn:hover {
    background: #059669;
}

.download-drawing-btn {
    background: #f59e0b;
    color: white;
}

.download-drawing-btn:hover {
    background: #d97706;
}

.pdf-upload-section h3 {
    text-align: center;
    color: #374151;
    margin-bottom: 25px;
    font-size: 1.5rem;
    font-weight: 600;
}

.upload-area {
    border: 3px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    background: #f9fafb;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #4f46e5;
    background: #f0f9ff;
}

.upload-area.dragover {
    border-color: #4f46e5;
    background: #e0f2fe;
    transform: scale(1.02);
}

.upload-content i {
    font-size: 3rem;
    color: #6b7280;
    margin-bottom: 15px;
}

.upload-content p {
    color: #6b7280;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.upload-btn {
    padding: 12px 24px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    background: #3730a3;
}

.pdf-preview {
    margin-top: 30px;
    text-align: center;
}

.pdf-preview h4 {
    color: #374151;
    margin-bottom: 20px;
    font-weight: 600;
}

.pdf-canvas-container {
    position: relative;
    display: inline-block;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

#pdfCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#signatureOverlay {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    pointer-events: none;
    z-index: 10;
}

.drawing-mode-btn.active {
    background: #10b981 !important;
}

.pdf-drawing-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    flex-wrap: wrap;
}

.drawing-mode-btn, .clear-drawing-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.drawing-mode-btn {
    background: #4f46e5;
    color: white;
}

.drawing-mode-btn:hover {
    background: #3730a3;
}

.drawing-mode-btn.active {
    background: #10b981;
}

.clear-drawing-btn {
    background: #ef4444;
    color: white;
}

.clear-drawing-btn:hover {
    background: #dc2626;
}

.pdf-pen-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.pdf-pen-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
}

.pdf-pen-controls input[type="range"] {
    width: 80px;
}

.pdf-pen-controls input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.pdf-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.signature-position-controls,
.pdf-signature-selection {
    background: #f9fafb;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.signature-position-controls h5,
.pdf-signature-selection h5 {
    color: #374151;
    margin-bottom: 15px;
    font-weight: 600;
}

.position-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.position-controls label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #6b7280;
}

.position-controls input[type="range"] {
    flex: 1;
}

#signatureStyleSelect,
#pdfSignatureText {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
}

.pdf-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.apply-signature-btn,
.download-pdf-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.apply-signature-btn {
    background: #4f46e5;
    color: white;
}

.apply-signature-btn:hover {
    background: #3730a3;
}

.download-pdf-btn {
    background: #10b981;
    color: white;
}

.download-pdf-btn:hover {
    background: #059669;
}

/* Signature Styles Gallery */
.signature-styles-gallery {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.signature-styles-gallery h3 {
    text-align: center;
    color: #374151;
    margin-bottom: 25px;
    font-size: 1.5rem;
    font-weight: 600;
}

.styles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.signature-style-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.signature-style-card:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.signature-style-card.selected {
    border-color: #4f46e5;
    background: #f0f9ff;
    box-shadow: 0 5px 20px rgba(79, 70, 229, 0.2);
}

.signature-preview {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.signature-style-name {
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
}

.signature-style-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.select-style-btn, .download-style-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.select-style-btn {
    background: #4f46e5;
    color: white;
}

.select-style-btn:hover {
    background: #3730a3;
}

.download-style-btn {
    background: #10b981;
    color: white;
}

.download-style-btn:hover {
    background: #059669;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

/* Controls Panel */
.controls-panel {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    height: fit-content;
}

.control-group {
    margin-bottom: 25px;
}

.control-group h4 {
    margin-bottom: 12px;
    color: #374151;
    font-weight: 600;
}

/* Mode Selector */
.mode-selector h3 {
    margin-bottom: 15px;
    color: #374151;
    font-weight: 600;
}

.mode-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.mode-btn.active {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.mode-btn:hover {
    border-color: #4f46e5;
    background: #f0f9ff;
}

.mode-btn.active:hover {
    background: #3730a3;
}

/* Input Styles */
input[type="text"], select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #4f46e5;
}

/* Style Options */
.style-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.style-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Color Palette */
.color-palette, .bg-color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.color-option, .bg-color-option {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.color-option.active, .bg-color-option.active {
    border-color: #4f46e5;
    transform: scale(1.1);
}

.color-option:hover, .bg-color-option:hover {
    transform: scale(1.05);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Range Inputs */
input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

/* Signature Area */
.signature-area {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.canvas-container {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    background: transparent;
}

#signatureCanvas {
    display: block;
    cursor: crosshair;
    width: 100%;
    height: 300px;
}

.type-signature {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    color: #000;
    white-space: nowrap;
    pointer-events: none;
    display: none;
}

/* Canvas Actions */
.canvas-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clear-btn {
    background: #ef4444;
    color: white;
}

.clear-btn:hover {
    background: #dc2626;
}

.undo-btn {
    background: #f59e0b;
    color: white;
}

.undo-btn:hover {
    background: #d97706;
}

/* Download Section */
.download-section h4 {
    margin-bottom: 15px;
    color: #374151;
    font-weight: 600;
}

/* PDF mode specific styling */
.pdf-mode-active .main-content {
    display: none !important;
}

.pdf-mode-active .gallery-section {
    display: none !important;
}

/* Type mode specific styling - Hide color and control panels */
.type-mode-active .controls-panel {
    display: none !important;
}

.type-mode-active .signature-area {
    display: none !important;
}

.download-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.download-btn {
    padding: 12px 20px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.download-btn:hover {
    background: #059669;
    transform: translateY(-2px);
}

/* Gallery Section */
.gallery-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.gallery-section h3 {
    margin-bottom: 20px;
    color: #374151;
    font-weight: 600;
}

.signatures-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.saved-signature {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    background: #f9fafb;
    transition: all 0.3s ease;
    cursor: pointer;
}

.saved-signature:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.saved-signature img {
    max-width: 100%;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
}

.saved-signature-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.saved-signature-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.use-btn {
    background: #4f46e5;
    color: white;
}

.delete-btn {
    background: #ef4444;
    color: white;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .controls-panel {
        order: 2;
    }
    
    .signature-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .top-mode-buttons {
        flex-direction: column;
        gap: 15px;
    }
    
    .top-mode-btn {
        padding: 20px 15px;
    }
    
    .pdf-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .pdf-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .name-input-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .name-input-container input {
        width: 100%;
    }
    
    .styles-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .mode-buttons {
        flex-direction: column;
    }
    
    .download-buttons {
        flex-direction: column;
    }
    
    .canvas-actions {
        flex-direction: column;
    }
    
    .color-palette, .bg-color-palette {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .signatures-gallery {
        grid-template-columns: 1fr;
    }
}

/* Animation for loading */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container > * {
    animation: fadeIn 0.6s ease-out;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3730a3;
}
