/* ========================================
   MAIN STYLES - Core application styles
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f1419;
    min-height: 100vh;
    padding: 20px;
    color: #e4e7eb;
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #1a1f2e;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 1px solid #2d3548;
}

.main-content {
    padding: 30px;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h2 {
    color: #e4e7eb;
    margin-bottom: 20px;
    font-size: 1.8em;
    font-weight: 600;
}

h3 {
    color: #9ca3af;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 500;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-primary {
    background: #3b82f6;
    color: white;
    padding: 15px 35px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #4b5563;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-small {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-logout {
    background: rgba(220, 38, 38, 0.1);
    color: #ef4444;
    padding: 12px 24px;
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-logout:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-remove {
    padding: 12px 20px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

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

.btn-copy {
    background: #3b82f6;
    color: white;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-copy:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #9ca3af;
    font-size: 0.95em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #3d4a5c;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: #1a1f2e;
    color: #e4e7eb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    font-family: 'Courier New', monospace;
    resize: vertical;
}

/* ========================================
   LOADING & ANIMATIONS
   ======================================== */

.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #252d3d;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 30px rgba(59, 130, 246, 0.6); }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

/* Apply animations to elements */
.container {
    animation: fadeIn 0.5s ease-out;
}

section {
    animation: fadeIn 0.6s ease-out;
    animation-fill-mode: both;
}

section:nth-child(1) { animation-delay: 0.1s; }
section:nth-child(2) { animation-delay: 0.2s; }
section:nth-child(3) { animation-delay: 0.3s; }

.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    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.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:active {
    animation: bounce 0.3s ease;
}

.error-message {
    animation: slideInLeft 0.4s ease-out, shake 0.5s ease 0.4s;
}

.success-message {
    animation: slideInRight 0.4s ease-out;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    animation: glow 2s ease-in-out infinite;
}

/* Loading shimmer effect */
.loading-shimmer {
    background: linear-gradient(90deg, #252d3d 0%, #3d4a5c 50%, #252d3d 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Hover effects */
.btn-secondary,
.btn-small {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-secondary:hover {
    box-shadow: 0 4px 12px rgba(75, 85, 99, 0.4);
}

.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}

/* Form animations */
.form-group {
    position: relative;
}

.form-group input,
.form-group select,
.form-group textarea {
    transition: all 0.3s ease;
}

.form-group label {
    transition: all 0.3s ease;
}

/* Spinner enhancements */
.spinner {
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 4px solid transparent;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1.5s linear infinite reverse;
}

/* ========================================
   MESSAGES & ALERTS
   ======================================== */

.error-message {
    background: #2d1f1f;
    border: 1px solid #dc2626;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: #fca5a5;
}

.error-message h3 {
    color: #ef4444;
    margin-bottom: 10px;
}

.success-message {
    background: #1f2d23;
    border: 1px solid #10b981;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: #86efac;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.empty-state p:first-child {
    font-size: 1.2em;
    margin-bottom: 10px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Reset for mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow-x: hidden;
}

/* Buttons - Touch friendly */
.btn-primary,
.btn-secondary,
.btn-logout,
.btn-remove,
.btn-copy {
    min-height: 44px;
    min-width: 44px;
}

/* Form inputs - Prevent iOS zoom */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    font-size: 16px !important;
}

/* Tablet and below (768px and down) */
@media screen and (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    .main-content {
        padding: 15px;
    }

    h2 {
        font-size: 1.4em;
        margin-bottom: 15px;
    }

    h3 {
        font-size: 1.1em;
    }

    /* Buttons stack on mobile */
    .btn-primary {
        width: 100%;
        padding: 12px 25px;
        font-size: 1em;
    }

    .btn-secondary,
    .btn-logout {
        width: 100%;
        margin-top: 10px;
    }

    /* Forms */
    .form-group {
        margin-bottom: 15px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px;
    }

    /* Modal responsive */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
        max-height: 90vh;
    }

    /* Error and success messages */
    .error-message,
    .success-message {
        padding: 15px;
        font-size: 0.9em;
    }

    /* Empty state */
    .empty-state {
        padding: 40px 15px;
    }
}

/* Mobile (480px and down) */
@media screen and (max-width: 480px) {
    .main-content {
        padding: 10px;
    }

    h2 {
        font-size: 1.2em;
    }

    h3 {
        font-size: 1em;
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 20px;
        font-size: 0.95em;
    }

    .btn-small {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .modal-content {
        width: 100%;
        margin: 0;
        padding: 15px;
        border-radius: 0;
        max-height: 100vh;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* Desktop (1025px and up) */
@media screen and (min-width: 1025px) {
    body {
        padding: 20px;
    }

    .main-content {
        padding: 30px;
    }
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
    button,
    .btn-primary,
    .btn-secondary,
    .btn-logout,
    input[type="submit"] {
        min-height: 48px;
        min-width: 48px;
    }

    button:active {
        transform: scale(0.97);
    }
}

/* Landscape mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        margin: 2% auto;
        max-height: 95vh;
    }

    .main-content {
        padding: 15px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .container {
        border: 2px solid #fff;
    }

    button,
    input,
    select,
    textarea {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    body {
        padding: 0;
    }

    .container {
        box-shadow: none;
        border: none;
    }

    .btn-logout,
    button {
        display: none;
    }
}
