/* CSS Variables for Theme */
:root {
    --background-color: #f5f5f5;
    --card-background: #ffffff;
    --text-color: #333333;
    --accent-color: #007bff;
    --border-color: #e0e0e0;
    --foreground-disabled: #999999;
    --error-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
}

[data-theme="dark"] {
    --background-color: #1a1a1a;
    --card-background: #2d2d2d;
    --text-color: #ffffff;
    --accent-color: #0d6efd;
    --border-color: #404040;
    --foreground-disabled: #666666;
    --error-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Container */
.pin-login-container {
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--background-color);
    position: relative;
}

.pin-login-card {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 1px solid var(--border-color);
}

/* Logo Section */
.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.app-logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
}

.app-title {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-color);
    margin: 0;
}

.login-subtitle {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 30px;
}

/* PIN Input */
.pin-input-container {
    margin-bottom: 30px;
}

.pin-input {
    width: 100%;
    max-width: 300px;
    height: 60px;
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 0 20px;
    font-size: 18px;
    text-align: center;
    background: var(--card-background);
    color: var(--text-color);
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.pin-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.pin-input::placeholder {
    color: var(--foreground-disabled);
}

/* Login Button */
.login-button-container {
    margin-bottom: 30px;
}

.login-button {
    width: 100%;
    max-width: 300px;
    height: 60px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.login-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.login-button:active {
    transform: translateY(0);
}

/* Settings Section */
.settings-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.settings-button {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.settings-button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.version-text {
    color: var(--foreground-disabled);
    font-size: 14px;
}

/* Dialog Styles */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.dialog {
    background: var(--card-background);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dialog-header h3 {
    color: var(--text-color);
    font-size: 20px;
    margin: 0;
}

.dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--foreground-disabled);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.dialog-content {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.server-input {
    flex: 2;
}

.port-input {
    flex: 1;
}

.form-input, .form-select {
    width: 100%;
    height: 45px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0 15px;
    font-size: 16px;
    background: var(--card-background);
    color: var(--text-color);
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 500;
}

.test-connection-btn {
    width: 100%;
    height: 45px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.test-connection-btn:hover {
    background: #0056b3;
}

.dialog-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.password-cancel-btn, .password-login-btn,
.settings-save-btn, .settings-exit-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.password-cancel-btn, .settings-exit-btn {
    background: var(--border-color);
    color: var(--text-color);
}

.password-login-btn, .settings-save-btn {
    background: var(--accent-color);
    color: white;
}

.password-cancel-btn:hover, .settings-exit-btn:hover {
    background: var(--foreground-disabled);
}

.password-login-btn:hover, .settings-save-btn:hover {
    background: #0056b3;
}

/* Toast Styles */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
    font-weight: 500;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Progress Dialog */
.progress-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.progress-dialog {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 300px;
    width: 90%;
}

.progress-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.progress-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-title {
    color: var(--text-color);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.progress-subtitle {
    color: var(--foreground-disabled);
    font-size: 14px;
    margin: 0;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .pin-login-container {
        padding: 10px;
    }
    
    .pin-login-card {
        padding: 30px 20px;
    }
    
    .app-title {
        font-size: 24px;
    }
    
    .login-subtitle {
        font-size: 18px;
    }
    
    .pin-input, .login-button {
        height: 55px;
        font-size: 16px;
    }
    
    .dialog {
        padding: 20px;
        margin: 20px;
    }
    
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
    }
    
    .progress-dialog {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .progress-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
    
    .progress-title {
        font-size: 16px;
    }
    
    .progress-subtitle {
        font-size: 13px;
    }
}

/* iOS Safari specific */
@supports (-webkit-touch-callout: none) {
    .pin-login-container {
        height: -webkit-fill-available;
    }
    
    .pin-login-card {
        max-height: -webkit-fill-available;
    }
}
