/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #667eea;
}

header p {
    font-size: 1.1rem;
    color: #666;
}

/* Input section */
.input-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#longUrl {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#longUrl:focus {
    outline: none;
    border-color: #667eea;
}

#shortenBtn, #generateBtn {
    padding: 15px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

#shortenBtn:hover, #generateBtn:hover {
    background: #5a6fd8;
}

#shortenBtn:disabled, #generateBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Error message */
.error {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #fcc;
}

.hidden {
    display: none;
}

/* Result section */
.result {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.result-item {
    margin-bottom: 15px;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-item label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #495057;
}

.url-display {
    background: white;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    word-break: break-all;
    font-family: monospace;
}

.shortened-url {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shortened-url .url-display {
    flex: 1;
}

.copy-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.copy-btn:hover {
    background: #218838;
}

.copy-btn.copied {
    background: #17a2b8;
}

/* QR Code */
#qrcode {
    text-align: center;
    padding: 10px;
}

#qrcode canvas {
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* Instructions section */
.instructions {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.instructions h4 {
    color: #856404;
    margin-bottom: 15px;
}

.instructions pre {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    margin: 10px 0;
}

.instructions code {
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.instructions ol {
    margin: 10px 0;
    padding-left: 20px;
}

.instructions li {
    margin: 5px 0;
}

.edit-link {
    display: inline-block;
    background: #28a745;
    color: white;
    padding: 10px 15px;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 15px;
    transition: background-color 0.3s ease;
}

.edit-link:hover {
    background: #218838;
    color: white;
}

/* Info section */
.info-section {
    margin-bottom: 30px;
}

.info-box {
    background: #e7f3ff;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 20px;
}

.info-box h3 {
    color: #0c5460;
    margin-bottom: 15px;
}

.info-box p {
    margin-bottom: 10px;
    color: #0c5460;
}

.info-box ul {
    margin: 15px 0;
    padding-left: 20px;
}

.info-box li {
    margin: 8px 0;
    color: #0c5460;
}

.info-box code {
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    color: #495057;
}

.edit-button {
    display: inline-block;
    background: #0056b3;
    color: white;
    padding: 10px 15px;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 15px;
    transition: background-color 0.3s ease;
}

.edit-button:hover {
    background: #004085;
    color: white;
}

.links-section {
    margin-bottom: 30px;
}

.links-section h3 {
    margin-bottom: 15px;
    color: #495057;
}

.recent-links {
    max-height: 300px;
    overflow-y: auto;
}

.no-links {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

.link-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.link-info {
    flex: 1;
    min-width: 0;
}

.link-short {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
    word-break: break-all;
}

.link-original {
    font-size: 0.9rem;
    color: #6c757d;
    word-break: break-all;
}

.link-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.link-actions button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.link-actions button:hover {
    background: #545b62;
}

.link-actions .delete-btn {
    background: #dc3545;
}

.link-actions .delete-btn:hover {
    background: #c82333;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid #dee2e6;
    color: #6c757d;
    font-size: 0.9rem;
}

footer a {
    color: #667eea;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .shortened-url {
        flex-direction: column;
        align-items: stretch;
    }
    
    .link-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .link-actions {
        margin-left: 0;
        justify-content: center;
    }
}

/* Animation for success feedback */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result {
    animation: fadeIn 0.3s ease;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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