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

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

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

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 {
    color: #2c3e50;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

/* API Token Section */
.api-token-section {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.api-token-section .form-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.api-token-section label {
    font-weight: 600;
    color: #495057;
    min-width: 100px;
}

.token-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.token-status {
    font-size: 12px;
    padding: 5px 0;
    font-weight: 500;
}

.token-status.success {
    color: #28a745;
}

.token-status.error {
    color: #dc3545;
}

.token-status.warning {
    color: #ffc107;
}

/* Token Warning Boxes */
.token-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 20px;
    color: #856404;
    font-size: 14px;
    font-weight: 500;
    display: block;
}

.btn.btn-success {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    font-weight: 600;
}

.btn.btn-success:hover {
    background: linear-gradient(45deg, #218838, #1ea085);
    transform: translateY(-1px);
}

/* Disabled element styling */
input:disabled,
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f8f9fa !important;
}

button:disabled {
    background: #6c757d !important;
}

button:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Loading button effects */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.btn.loading.btn-primary::after {
    border-top-color: #ffffff;
}

.btn.loading.btn-secondary::after {
    border-top-color: #ffffff;
}

/* Pulse effect for processing */
.btn.processing {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Results section highlight */
.results-highlight {
    animation: highlightFade 3s ease-in-out;
    border: 2px solid #28a745;
}

@keyframes highlightFade {
    0% {
        border-color: #28a745;
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.5);
    }
    100% {
        border-color: transparent;
        box-shadow: none;
    }
}

/* Loading indicator styles */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    font-size: 18px;
    font-weight: 500;
    color: #495057;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px dashed #6c757d;
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

.loading::before {
    content: "";
    width: 20px;
    height: 20px;
    border: 3px solid #e9ecef;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Notification system */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 350px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.notification-error {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.notification-info {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

/* Button hover effects enhancement */
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

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

.tabs {
    display: flex;
    background: white;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: #ecf0f1;
    border: none;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: #d5dbdb;
}

.tab-button.active {
    background: #3498db;
    color: white;
}

.tab-content {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.tab-content.active {
    display: block;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.card h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.3em;
}

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

.form-row {
    display: flex;
    gap: 15px;
    align-items: end;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

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

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 8px 12px;
    font-size: 0.9em;
}

.btn-danger:hover {
    background: #c0392b;
}

pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 15px;
}

.rectangle-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #3498db;
}

.rectangle-item input {
    margin-bottom: 0;
}

.rect-id { flex: 1; }
.rect-width { flex: 1; }
.rect-height { flex: 1; }
.rect-weight { flex: 1; }
.rect-bend { flex: 1; }

.endpoint {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #27ae60;
}

.endpoint h3 {
    color: #27ae60;
    font-family: 'Courier New', monospace;
}

.api-links {
    text-align: center;
    margin-top: 30px;
}

.result-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.result-success {
    border-left: 4px solid #27ae60;
}

.result-error {
    border-left: 4px solid #e74c3c;
}

.placement-image {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin: 15px 0;
}

.placed-rectangles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.placed-rect {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #3498db;
}

.warnings {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.warnings h4 {
    color: #8b7300;
    margin-bottom: 10px;
}

.warnings ul {
    margin-left: 20px;
}

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

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #3498db;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.feedback-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .placed-rectangles {
        grid-template-columns: 1fr;
    }
}

.hidden {
    display: none;
}