/* Enhanced Styles for Kriptografi App with Performance Optimizations */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

.cipher-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    overflow: hidden;
}

.cipher-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.cipher-btn:hover::before {
    left: 100%;
}

.cipher-btn:hover {
    background-color: #e9ecef;
    transform: translateX(5px);
}

.cipher-btn.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.cipher-btn.switching {
    opacity: 0.7;
    pointer-events: none;
}

.cipher-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

#cipher-content {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 400px;
}

.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    transform: scale(1.02);
}

.btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
    transition: transform 0.1s;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:active::after {
    width: 100px;
    height: 100px;
}

.matrix-input {
    width: 60px;
    text-align: center;
    margin: 2px;
    transition: all 0.2s ease;
}

.matrix-input:focus {
    transform: scale(1.1);
    z-index: 10;
    position: relative;
}

.playfair-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    max-width: 250px;
    margin: 0 auto;
}

.playfair-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    background-color: white;
}

.algorithm-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.step {
    flex: 1;
    text-align: center;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.step.active {
    background-color: #007bff;
    color: white;
}

.result-highlight {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border-radius: 5px;
    padding: 15px;
    font-family: monospace;
    font-size: 1.1em;
    word-break: break-all;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
}

/* Animation for results */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Matrix display */
.matrix-display {
    font-family: monospace;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    margin: 10px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .matrix-input {
        width: 50px;
    }

    .playfair-cell {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .step {
        font-size: 12px;
        padding: 8px 4px;
    }
}

/* Loading spinner customization */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Copy button animation */
.btn-copy {
    position: relative;
    overflow: hidden;
}

.btn-copy::after {
    content: "Disalin!";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.btn-copy.copied::after {
    transform: translateY(0);
}

/* Highlight animation */
.highlight {
    animation: highlightPulse 1s ease-in-out;
}

@keyframes highlightPulse {
    0% { background-color: transparent; }
    50% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}

/* Enhanced Loading and Animation Styles */
.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Enhanced fade in animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Processing info styles */
.processing-info {
    background: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 0.85em;
}

/* Enhanced progress bar */
.progress {
    background-color: rgba(0, 123, 255, 0.1);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(45deg, #007bff, #0056b3);
    transition: width 0.3s ease;
}

/* Enhanced modal styling */
.modal-content {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-body {
    padding: 2rem;
}

/* Smooth transitions for all elements */
* {
    scroll-behavior: smooth;
}

/* Error and success states */
.alert {
    border: none;
    border-radius: 10px;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.alert-success {
    background: linear-gradient(135deg, #28a745, #218838);
    color: white;
}

/* Enhanced form styling */
.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

/* Enhanced results section */
#results-section {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#result-input, #result-output {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    word-break: break-word;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    transition: all 0.3s ease;
}

#result-output {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

/* Loading skeleton animation */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Hover effects for interactive elements */
.interactive-element:hover {
    transform: scale(1.02);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Notification animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Loading pulse animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading-pulse {
    animation: pulse 1.5s infinite;
}

/* Enhanced spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Focus visible for better accessibility */
*:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .card {
        margin-bottom: 15px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .btn {
        width: 100%;
        margin-bottom: 10px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .hill-matrix-container table {
        font-size: 12px;
    }

    .hill-matrix-container input {
        width: 40px;
        height: 30px;
        font-size: 11px;
    }

    .nav-pills .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }

    .matrix-input {
        width: 50px;
    }

    .playfair-cell {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .step {
        font-size: 12px;
        padding: 8px 4px;
    }
}

/* Enhanced Performance CSS */
.card, .btn, .form-control, .modal {
    will-change: auto;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-dots::after,
    .notification {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border-width: 2px;
        border-color: #000;
    }

    .btn-primary {
        border: 2px solid #000;
    }

    .notification {
        border: 2px solid currentColor;
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .card {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #e0e0e0;
    }

    .form-control {
        background-color: #404040;
        border-color: #555;
        color: #e0e0e0;
    }

    .form-control:focus {
        background-color: #404040;
        border-color: #007bff;
        color: #e0e0e0;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }

    .notification {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }

    .notification.success {
        background-color: #155724;
        border-color: #28a745;
    }

    .notification.error {
        background-color: #721c24;
        border-color: #dc3545;
    }

    .notification.warning {
        background-color: #856404;
        border-color: #ffc107;
    }
}

/* Print styles */
@media print {
    .btn, .nav-pills, .modal {
        display: none !important;
    }

    .card {
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* Notification styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 300px;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
    background-color: #fff;
    border: 1px solid #dee2e6;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.notification.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.notification.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.notification.warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.notification.slide-out {
    animation: slideOutRight 0.3s ease-in forwards;
}

    .cipher-btn:hover {
        transform: none;
    }

    .card:hover {
        transform: none;
    }

    .form-control:focus {
        transform: none;
    }

    /* Disable complex animations on mobile for better performance */
    .btn::after,
    .cipher-btn::before {
        display: none;
    }
